Documentation ¶
Overview ¶
Package templates contains the various Go code templates used by xo.
Index ¶
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func MustAsset(name string) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- type EnumTemplate
- type FkTemplate
- type FuncTemplate
- type IdxTemplate
- type ProcTemplate
- type TableTemplate
Constants ¶
This section is empty.
Variables ¶
var KnownTypeMap = map[string]bool{ "bool": true, "string": true, "byte": true, "rune": true, "int": true, "int16": true, "int32": true, "int64": true, "uint": true, "uint8": true, "uint16": true, "uint32": true, "uint64": true, "float32": true, "float64": true, }
KnownTypeMap is the collection of known Go types.
var ShortNameTypeMap = map[string]string{
"bool": "b",
"string": "s",
"byte": "b",
"rune": "r",
"int": "i",
"int16": "i",
"int32": "i",
"int64": "i",
"uint": "u",
"uint8": "u",
"uint16": "u",
"uint32": "u",
"uint64": "u",
"float32": "f",
"float64": "f",
}
ShortNameTypeMap is the collection of Go style short names for types, mainly used for use with declaring a func receiver on a type.
var Tpls = map[string]*template.Template{}
Tpls is the collection of template assets.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type EnumTemplate ¶
EnumTemplate is a template item for a enum.
type FkTemplate ¶
type FkTemplate struct { Type string ColumnName string Field string RefType string RefField string }
FkTemplate is a template item for a foreign relationship on a table.
type FuncTemplate ¶
type FuncTemplate struct { Name string Type string Query []string QueryComments []string Parameters [][]string OnlyOne bool Comment string Table *TableTemplate }
FuncTemplate is a template item for a custom query.
type IdxTemplate ¶
type IdxTemplate struct { Type string Name string TableSchema string TableName string IndexName string IsUnique bool Plural string Comment string Fields []*models.Column Table *TableTemplate }
IdxTemplate is a template item for a index into a table.
type ProcTemplate ¶
type ProcTemplate struct { Name string ReturnType string NilReturnType string TableSchema string ProcName string ProcParameterNames string ProcParameterTypes string ProcReturnType string Comment string Parameters []*models.Column }
ProcTemplate is a template item for a stored procedure.