code: func NewGenerator(genfunc string, imports []*codegen.ImportSpec, flags map[string]string, customflags []string) (*Generator, error) {
  	var (
  		outDir, designPkgPath string
  		debug                 bool
  	)
  
  	if o, ok := flags["out"]; ok {
  		outDir = o
  	}
  	if d, ok := flags["design"]; ok {
  		designPkgPath = d
  	}
  	if d, ok := flags["debug"]; ok {
  		var err error
  		debug, err = strconv.ParseBool(d)
  		if err != nil {
  			return nil, fmt.Errorf("failed to parse debug flag: %s", err)
  		}
  	}
  
  	return &Generator{
  		Genfunc:       genfunc,
  		Imports:       imports,
  		Flags:         flags,
  		CustomFlags:   customflags,
  		OutDir:        outDir,
  		DesignPkgPath: designPkgPath,
  		debug:         debug,
  	}, nil
  }
docs: // NewGenerator returns a meta generator that can run an actual Generator
  // given its factory method and command line flags.