func (p *Program) ImportFile(path string) (*Package, error) {
	if p.Packages == nil {
		p.Packages = make(map[string]*Package)
	}
	if _, ok := p.Packages[path]; ok {
		// unlikely
		return nil, errors.New("loader: cannot import file that is already imported as package: " + path)
	}

	file, err := p.parseFile(path, parser.ImportsOnly)
	if err != nil {
		return nil, err
	}
	buildPkg := &build.Package{
		Dir:        filepath.Dir(path),
		ImportPath: path,
		GoFiles:    []string{filepath.Base(path)},
	}
	for _, importSpec := range file.Imports {
		buildPkg.Imports = append(buildPkg.Imports, importSpec.Path.Value[1:len(importSpec.Path.Value)-1])
	}
	p.sorted = nil // invalidate the sorted order of packages
	pkg := p.newPackage(buildPkg)
	p.Packages[buildPkg.ImportPath] = pkg
	return pkg, nil
}
// ImportFile loads and parses the import statements in the given path and
// creates a pseudo-package out of it.
ImportFile loads and parses the import statements in the given path and
creates a pseudo-package out of it.
// ImportFile loads and parses the import statements in the given path and // creates a pseudo - package out of it .
func (p *Program) ImportFile(path string) (*Package, error) {
	if p.Packages == nil {
		p.Packages = make(map[string]*Package)
	}
	if _, ok := p.Packages[path]; ok {
		return nil, errors.New("loader: cannot import file that is already imported as package: " + path)
	}
	file, err := p.parseFile(path, parser.ImportsOnly)
	if err != nil {
		return nil, err
	}
	buildPkg := &build.Package{
		Dir:        filepath.Dir(path),
		ImportPath: path,
		GoFiles:    []string{filepath.Base(path)},
	}
	for _, importSpec := range file.Imports {
		buildPkg.Imports = append(buildPkg.Imports, importSpec.Path.Value[1:len(importSpec.Path.Value)-1])
	}
	p.sorted = nil 
	pkg := p.newPackage(buildPkg)
	p.Packages[buildPkg.ImportPath] = pkg
	return pkg, nil
}
func ( p * Program ) ImportFile ( path string ) ( * Package , error ) { if p . Packages == nil { p . Packages = make ( map [ string ] * Package ) } if _ , ok := p . Packages [ path ] ; ok { return nil , errors . New ( " " + path ) } file , err := p . parseFile ( path , parser . ImportsOnly ) if err != nil { return nil , err } buildPkg := & build . Package { Dir : filepath . Dir ( path ) , ImportPath : path , GoFiles : [ ] string { filepath . Base ( path ) } , } for _ , importSpec := range file . Imports { buildPkg . Imports = append ( buildPkg . Imports , importSpec . Path . Value [ 1 : len ( importSpec . Path . Value ) - 1 ] ) } p . sorted = nil pkg := p . newPackage ( buildPkg ) p . Packages [ buildPkg . ImportPath ] = pkg return pkg , nil }
ImportFile loads and parses the import statements in the given path and
creates a pseudo-package out of it.
ImportFile loads and parses the import statements in the given path and creates a pseudo - package out of it .
// unlikely // invalidate the sorted order of packages