code: func (sd structDef) generate(dir string) error {
  	// generate enums
  	for _, f := range sd.Fields {
  		if f.Enum != nil {
  			if err := f.Enum.generate(dir); err != nil {
  				return err
  			}
  		}
  	}
  	if sd.Enum != nil {
  		return sd.Enum.generate(dir)
  	}
  	fileName := filepath.Join(dir, sd.Name+".go")
  	return commons.GenerateFile(sd, structTemplateLocation, "struct_template", fileName, true)
  }
docs: // generate Go struct