gotpl

package
v0.0.0-...-724cd65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gotpl provides a Go template for xo.

Index

Constants

View Source
const (
	FirstKey      xo.ContextKey = "first"
	KnownTypesKey xo.ContextKey = "known-types"
	ShortsKey     xo.ContextKey = "shorts"
	NotFirstKey   xo.ContextKey = "not-first"
	Int32Key      xo.ContextKey = "int32"
	Uint32Key     xo.ContextKey = "uint32"
	PkgKey        xo.ContextKey = "pkg"
	TagKey        xo.ContextKey = "tag"
	ImportKey     xo.ContextKey = "import"
	UUIDKey       xo.ContextKey = "uuid"
	CustomKey     xo.ContextKey = "custom"
	ConflictKey   xo.ContextKey = "conflict"
	InitialismKey xo.ContextKey = "initialism"
	EscKey        xo.ContextKey = "esc"
	FieldTagKey   xo.ContextKey = "field-tag"
	ContextKey    xo.ContextKey = "context"
	InjectKey     xo.ContextKey = "inject"
	InjectFileKey xo.ContextKey = "inject-file"
	LegacyKey     xo.ContextKey = "legacy"
)

Context keys.

Variables

View Source
var Files embed.FS

Files are the embedded Go templates.

Functions

func Conflict

func Conflict(ctx context.Context) string

Conflict returns conflict from the context.

func Context

func Context(ctx context.Context) string

Context returns context from the context.

func Custom

func Custom(ctx context.Context) string

Custom returns custom-pkg from the context.

func Esc

func Esc(ctx context.Context, esc string) bool

Esc indicates if esc should be escaped based from the context.

func FieldTag

func FieldTag(ctx context.Context) string

FieldTag returns field-tag from the context.

func First

func First(ctx context.Context) *bool

First returns first from the context.

func Imports

func Imports(ctx context.Context) []string

Imports returns package imports from the context.

func Inject

func Inject(ctx context.Context) string

Inject returns inject from the context.

func InjectFile

func InjectFile(ctx context.Context) string

InjectFile returns inject-file from the context.

func Int32

func Int32(ctx context.Context) string

Int32 returns int32 from the context.

func KnownTypes

func KnownTypes(ctx context.Context) map[string]bool

KnownTYpes returns known-types from the context.

func Legacy

func Legacy(ctx context.Context) bool

Legacy returns legacy from the context.

func NotFirst

func NotFirst(ctx context.Context) bool

NotFirst returns not-first from the context.

func Pkg

func Pkg(ctx context.Context) string

Pkg returns pkg from the context.

func Shorts

func Shorts(ctx context.Context) map[string]string

Shorts retruns shorts from the context.

func Tags

func Tags(ctx context.Context) []string

Tags returns tags from the context.

func Uint32

func Uint32(ctx context.Context) string

Uint32 returns uint32 from the context.

Types

type Enum

type Enum struct {
	GoName  string
	SQLName string
	Values  []EnumValue
	Comment string
}

Enum is a enum type template.

type EnumValue

type EnumValue struct {
	GoName     string
	SQLName    string
	ConstValue int
}

EnumValue is a enum value template.

type Field

type Field struct {
	GoName     string
	SQLName    string
	Type       string
	Zero       string
	IsPrimary  bool
	IsSequence bool
	Comment    string
}

Field is a field template.

type ForeignKey

type ForeignKey struct {
	GoName    string
	SQLName   string
	Table     Table
	Fields    []Field
	RefTable  string
	RefFields []Field
	RefFunc   string
	Comment   string
}

ForeignKey is a foreign key template.

type Index

type Index struct {
	SQLName   string
	Func      string
	Table     Table
	Fields    []Field
	IsUnique  bool
	IsPrimary bool
	Comment   string
}

Index is an index template.

type PackageImport

type PackageImport struct {
	Alias string
	Pkg   string
}

PackageImport holds information about a Go package import.

func (PackageImport) String

func (v PackageImport) String() string

String satisfies the fmt.Stringer interface.

type Proc

type Proc struct {
	Type           string
	GoName         string
	OverloadedName string
	SQLName        string
	Signature      string
	Params         []Field
	Returns        []Field
	Void           bool
	Overloaded     bool
	Comment        string
}

Proc is a stored procedure template.

type Query

type Query struct {
	Name        string
	Query       []string
	Comments    []string
	Params      []QueryParam
	One         bool
	Flat        bool
	Exec        bool
	Interpolate bool
	Type        Table
	Comment     string
}

Query is a custom query template.

type QueryParam

type QueryParam struct {
	Name        string
	Type        string
	Interpolate bool
	Join        bool
}

QueryParam is a custom query parameter template.

type Table

type Table struct {
	Type        string
	GoName      string
	SQLName     string
	PrimaryKeys []Field
	Fields      []Field
	Manual      bool
	Comment     string
}

Table is a type (ie, table/view/custom query) template.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL