func (p *Program) Import(path, srcDir string) (*Package, error) {
	if p.Packages == nil {
		p.Packages = make(map[string]*Package)
	}

	// Load this package.
	ctx := p.Build
	if p.ShouldOverlay(path) {
		ctx = p.OverlayBuild
	}
	buildPkg, err := ctx.Import(path, srcDir, build.ImportComment)
	if err != nil {
		return nil, err
	}
	if existingPkg, ok := p.Packages[buildPkg.ImportPath]; ok {
		// Already imported, or at least started the import.
		return existingPkg, nil
	}
	p.sorted = nil // invalidate the sorted order of packages
	pkg := p.newPackage(buildPkg)
	p.Packages[buildPkg.ImportPath] = pkg
	return pkg, nil
}
// Import loads the given package relative to srcDir (for the vendor directory).
// It only loads the current package without recursion.
Import loads the given package relative to srcDir (for the vendor directory).
It only loads the current package without recursion.
// Import loads the given package relative to srcDir ( for the vendor directory ) . // It only loads the current package without recursion .
func (p *Program) Import(path, srcDir string) (*Package, error) {
	if p.Packages == nil {
		p.Packages = make(map[string]*Package)
	}
	ctx := p.Build
	if p.ShouldOverlay(path) {
		ctx = p.OverlayBuild
	}
	buildPkg, err := ctx.Import(path, srcDir, build.ImportComment)
	if err != nil {
		return nil, err
	}
	if existingPkg, ok := p.Packages[buildPkg.ImportPath]; ok {
		return existingPkg, nil
	}
	p.sorted = nil 
	pkg := p.newPackage(buildPkg)
	p.Packages[buildPkg.ImportPath] = pkg
	return pkg, nil
}
func ( p * Program ) Import ( path , srcDir string ) ( * Package , error ) { if p . Packages == nil { p . Packages = make ( map [ string ] * Package ) } ctx := p . Build if p . ShouldOverlay ( path ) { ctx = p . OverlayBuild } buildPkg , err := ctx . Import ( path , srcDir , build . ImportComment ) if err != nil { return nil , err } if existingPkg , ok := p . Packages [ buildPkg . ImportPath ] ; ok { return existingPkg , nil } p . sorted = nil pkg := p . newPackage ( buildPkg ) p . Packages [ buildPkg . ImportPath ] = pkg return pkg , nil }
Import loads the given package relative to srcDir (for the vendor directory).
Import loads the given package relative to srcDir ( for the vendor directory ) .
// Load this package. // Already imported, or at least started the import. // invalidate the sorted order of packages