Documentation ¶
Index ¶
- Variables
- func AddCommand(cmds ...*cobra.Command)
- func BaseTemplateData() map[string]interface{}
- func OnGen(f func())
- func OnHook(name string, f HookFunc)
- func Run(items []ConfigItem)
- func WriteFile(outFolder string, fileName string, code []byte)
- func WriteFileDisclaimer(out *bytes.Buffer)
- func WriteImports(out *bytes.Buffer, imports map[string]string)
- func WritePackageName(out *bytes.Buffer, pkgName string)
- type ConfigItem
- type ConfigStruct
- type HookFunc
- type Plugin
- type TemplateList
Constants ¶
This section is empty.
Variables ¶
var TemplateFunctions = template.FuncMap{ "quoteWrap": func(s string) string { return fmt.Sprintf(`"%s"`, s) }, "id": strmangle.Identifier, "singular": strmangle.Singular, "plural": strmangle.Plural, "titleCase": strmangle.TitleCase, "titleCaseIdentifier": strmangle.TitleCaseIdentifier, "camelCase": strmangle.CamelCase, "join": func(sep string, slice []string) string { return strings.Join(slice, sep) }, "joinSlices": strmangle.JoinSlices, "stringMap": strmangle.StringMap, "prefixStringSlice": strmangle.PrefixStringSlice, "containsAny": strmangle.ContainsAny, "generateTags": strmangle.GenerateTags, "generateIgnoreTags": strmangle.GenerateIgnoreTags, "makeStringMap": strmangle.MakeStringMap, "import": templateImport, "goType": templateGoType, "typesGo": templateTypesGo, "setInclude": strmangle.SetInclude, "setComplement": strmangle.SetComplement, "whereClause": strmangle.WhereClause, "sqlColDefinitions": schema.SQLColDefinitions, "columnNames": schema.ColumnNames, "getModel": schema.GetModel, "quotes": func(s string) string { d := Config.Dialect lq := strmangle.QuoteCharacter(d.LQ) rq := strmangle.QuoteCharacter(d.RQ) return fmt.Sprintf("%s%s%s", lq, s, rq) }, "schemaModel": func(model string) string { d := Config.Dialect lq := strmangle.QuoteCharacter(d.LQ) rq := strmangle.QuoteCharacter(d.RQ) return strmangle.SchemaModel(lq, rq, model) }, "hook": hook, }
TemplateFunctions is a map of all the functions that get passed into the templates. If you wish to pass a new function into your own template, add a function pointer here.
Functions ¶
func AddCommand ¶
func BaseTemplateData ¶
func BaseTemplateData() map[string]interface{}
func Run ¶
func Run(items []ConfigItem)
func WriteFileDisclaimer ¶
WriteFileDisclaimer writes the disclaimer at the top with a trailing newline so the package name doesn't get attached to it.
func WriteImports ¶
WriteImports writes the import list, ignores errors since it's to the concrete buffer type which produces none
func WritePackageName ¶
WritePackageName writes the package name correctly, ignores errors since it's to the concrete buffer type which produces none
Types ¶
type ConfigItem ¶
type ConfigItem interface {
IsConfigItem()
}
type ConfigStruct ¶
type ConfigStruct struct { Items []ConfigItem Schema *schema.Schema Dialect queries.Dialect OutputPath string ModelsPackageName string }
var Config *ConfigStruct
func (*ConfigStruct) ModelsOutputPath ¶
func (c *ConfigStruct) ModelsOutputPath() string
type TemplateList ¶
func LoadTemplate ¶
func LoadTemplate(pkg string, path string) (*TemplateList, error)
LoadTemplate loads a single template file
func LoadTemplates ¶
func LoadTemplates(pkg string, path string) (*TemplateList, error)
LoadTemplates loads all of the template files in the specified directory.
func MustLoadTemplate ¶
func MustLoadTemplate(pkg string, path string) *TemplateList
func MustLoadTemplates ¶
func MustLoadTemplates(pkg string, path string) *TemplateList
func (*TemplateList) Execute ¶
func (t *TemplateList) Execute(data map[string]interface{}, filename string)
func (*TemplateList) ExecuteBuf ¶
func (t *TemplateList) ExecuteBuf(data map[string]interface{}, buf *bytes.Buffer)
func (*TemplateList) ExecuteSingleton ¶
func (t *TemplateList) ExecuteSingleton(data map[string]interface{})
func (TemplateList) Templates ¶
func (t TemplateList) Templates() []string
Templates returns the name of all the templates defined in the template list