code: func (g *Generator) Generate() (_ []string, err error) {
  	if g.API == nil {
  		return nil, fmt.Errorf("missing API definition, make sure design is properly initialized")
  	}
  
  	go utils.Catch(nil, func() { g.Cleanup() })
  
  	defer func() {
  		if err != nil {
  			g.Cleanup()
  		}
  	}()
  
  	if g.Target == "" {
  		g.Target = "app"
  	}
  
  	codegen.Reserved[g.Target] = true
  
  	mainFile := filepath.Join(g.OutDir, "main.go")
  	if g.Force {
  		os.Remove(mainFile)
  	}
  	_, err = os.Stat(mainFile)
  	if err != nil {
  		// ensure that the output directory exists before creating a new main
  		if err = os.MkdirAll(g.OutDir, 0755); err != nil {
  			return nil, err
  		}
  		if err = g.createMainFile(mainFile, funcMap(g.Target, nil)); err != nil {
  			return nil, err
  		}
  	}
  
  	err = g.API.IterateResources(func(r *design.ResourceDefinition) error {
  		filename, err := GenerateController(g.Force, g.Regen, g.Target, g.OutDir, "main", r.Name, r)
  		if err != nil {
  			return err
  		}
  
  		g.genfiles = append(g.genfiles, filename)
  		return nil
  	})
  	if err != nil {
  		return
  	}
  
  	return g.genfiles, nil
  }
docs: // Generate produces the skeleton main.