Documentation
¶
Overview ¶
This version is based on the original https://github.com/ent/ent/blob/master/entc/gen/func.go, which is a modified version of code from ent/ent
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( CoreTemplates = []CoreTemplate{ { Name: "client", FilePath: "client.go", }, { Name: "where", FilePath: "where.go", }, { Name: "error", FilePath: "error.go", }, } EntityTemplates = []EntityTemplate{ { Name: "model", FilePath: pkgf("%s.go"), }, } )
View Source
var ( // Funcs are the predefined template // functions used by the codegen. Funcs = template.FuncMap{ "hasSuffix": strings.HasSuffix, "lower": strings.ToLower, "pascal": pascal, "plural": plural, "replace": strings.ReplaceAll, "singular": rules.Singularize, "snake": snake, "split": strings.Split, "trim": strings.Trim, "upper": strings.ToUpper, } )
Functions ¶
Types ¶
type Config ¶
type Config struct { // Header allows users to provide an optional header signature for // the generated files. It defaults to the standard 'go generate' // format: '// Code generated by not, DO NOT EDIT.'. Header string // Target defines the filepath for the target directory that // holds the generated code. For example, "./project/not". // // By default, 'not postgres generate ...' uses './not' as a // target directory. Target string // Package defines the Go package path of the target directory // mentioned above. For example, "github.com/org/project/not". // // By default, 'not generate' uses "<project>/not" as a default package. Package string }
type CoreTemplate ¶
type Entity ¶
type Entity struct { *Config // Name is the name of the entity in the database schema. Name string // Fields holds all the primitive fields of this type. Fields []*Field }
Entity is a struct that represents a database table.
func (Entity) ClientName ¶
ClientName returns the struct name denoting the client of this type.
func (Entity) OptionsName ¶
OptionsName returns the name of the options struct.
func (Entity) PackageDir ¶
PackageDir returns the name of the package directory.
func (Entity) Receiver ¶
Receiver returns the receiver name of this node. It makes sure the receiver names doesn't conflict with import names.
func (Entity) WhereInputName ¶
WhereInputName returns the name of the where input struct.
type EntityTemplate ¶
Click to show internal directories.
Click to hide internal directories.