// Execute runs the complete code-generation cycle.
Execute runs the complete code-generation cycle.
// Execute runs the complete code - generation cycle .
func (g *generation) Execute() error {
	pkgs, err := packages.Load(g.packageConfig(), ".")
	if err != nil {
		return err
	}
	v := &visitation{
		gen:              g,
		includeReachable: g.config.reachable,
		packagePath:      pkgs[0].PkgPath,
		Types:            make(map[TypeID]visitableType),
		SourceTypes:      make(map[SourceName]visitableType),
	}
	g.visitation = v
	if g.config.union != "" {
		v.Root = namedInterfaceType{
			Union: g.union,
			v:     v,
		}
	}
	scopes := make([]*types.Scope, len(pkgs))
	for idx, pkg := range pkgs {
		scopes[idx] = pkg.Types.Scope()
	}
	if err := v.findSeedTypes(scopes); err != nil {
		return err
	}
	v.populateGeneratedTypes(scopes)
	return v.generateAPI()
}
func ( g * generation ) Execute ( ) error { pkgs , err := packages . Load ( g . packageConfig ( ) , " " ) if err != nil { return err } v := & visitation { gen : g , includeReachable : g . config . reachable , packagePath : pkgs [ 0 ] . PkgPath , Types : make ( map [ TypeID ] visitableType ) , SourceTypes : make ( map [ SourceName ] visitableType ) , } g . visitation = v if g . config . union != " " { v . Root = namedInterfaceType { Union : g . union , v : v , } } scopes := make ( [ ] * types . Scope , len ( pkgs ) ) for idx , pkg := range pkgs { scopes [ idx ] = pkg . Types . Scope ( ) } if err := v . findSeedTypes ( scopes ) ; err != nil { return err } v . populateGeneratedTypes ( scopes ) return v . generateAPI ( ) }
Execute runs the complete code-generation cycle.
Execute runs the complete code - generation cycle .
// This will return multiple packages.Package if we're also loading // test files. Note that the error here is whether or not the Load() // was able to perform its work. The underlying source may still have // syntax/type errors, but we ignore that in case of a "make clean" // situation, where we're likely to see code that depends on generated // code. // Synthesize a union interface, if configured.