func (p *Package) importRecursively() error {
	p.Importing = true
	for _, to := range p.Package.Imports {
		if to == "C" {
			// Do CGo processing in a later stage.
			continue
		}
		if _, ok := p.Imports[to]; ok {
			continue
		}
		importedPkg, err := p.Program.Import(to, p.Package.Dir)
		if err != nil {
			if err, ok := err.(*ImportCycleError); ok {
				err.Packages = append([]string{p.ImportPath}, err.Packages...)
			}
			return err
		}
		if importedPkg.Importing {
			return &ImportCycleError{[]string{p.ImportPath, importedPkg.ImportPath}, p.ImportPos[to]}
		}
		err = importedPkg.importRecursively()
		if err != nil {
			if err, ok := err.(*ImportCycleError); ok {
				err.Packages = append([]string{p.ImportPath}, err.Packages...)
			}
			return err
		}
		p.Imports[to] = importedPkg
	}
	p.Importing = false
	return nil
}
// importRecursively calls Program.Import() on all imported packages, and calls
// importRecursively() on the imported packages as well.
//
// Idempotent.
importRecursively calls Program.Import() on all imported packages, and calls
importRecursively() on the imported packages as well.

Idempotent.
// importRecursively calls Program . Import () on all imported packages and calls // importRecursively () on the imported packages as well . // // Idempotent .
func (p *Package) importRecursively() error {
	p.Importing = true
	for _, to := range p.Package.Imports {
		if to == "C" {
			continue
		}
		if _, ok := p.Imports[to]; ok {
			continue
		}
		importedPkg, err := p.Program.Import(to, p.Package.Dir)
		if err != nil {
			if err, ok := err.(*ImportCycleError); ok {
				err.Packages = append([]string{p.ImportPath}, err.Packages...)
			}
			return err
		}
		if importedPkg.Importing {
			return &ImportCycleError{[]string{p.ImportPath, importedPkg.ImportPath}, p.ImportPos[to]}
		}
		err = importedPkg.importRecursively()
		if err != nil {
			if err, ok := err.(*ImportCycleError); ok {
				err.Packages = append([]string{p.ImportPath}, err.Packages...)
			}
			return err
		}
		p.Imports[to] = importedPkg
	}
	p.Importing = false
	return nil
}
func ( p * Package ) importRecursively ( ) error { p . Importing = true for _ , to := range p . Package . Imports { if to == " " { continue } if _ , ok := p . Imports [ to ] ; ok { continue } importedPkg , err := p . Program . Import ( to , p . Package . Dir ) if err != nil { if err , ok := err . ( * ImportCycleError ) ; ok { err . Packages = append ( [ ] string { p . ImportPath } , err . Packages ... ) } return err } if importedPkg . Importing { return & ImportCycleError { [ ] string { p . ImportPath , importedPkg . ImportPath } , p . ImportPos [ to ] } } err = importedPkg . importRecursively ( ) if err != nil { if err , ok := err . ( * ImportCycleError ) ; ok { err . Packages = append ( [ ] string { p . ImportPath } , err . Packages ... ) } return err } p . Imports [ to ] = importedPkg } p . Importing = false return nil }
importRecursively calls Program.Import() on all imported packages, and calls
importRecursively() on the imported packages as well.
importRecursively calls Program . Import () on all imported packages and calls importRecursively () on the imported packages as well .
// Do CGo processing in a later stage.