generator

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxPathLength = 260 // Hard limit on Windows
	MinFileNameLength    = 2
	FileSuffixLength     = 5 // Leave space for at least single-digit index if needed
	FileSuffix           = ".go"
)

FileOpenFlags are the flags that are used when opening a file on non-Windows systems

Variables

View Source
var ZserioTypeToGoType = map[string]string{

	"int8":   "int8",
	"int16":  "int16",
	"int32":  "int32",
	"int64":  "int64",
	"uint8":  "uint8",
	"uint16": "uint16",
	"uint32": "uint32",
	"uint64": "uint64",

	"varint":    "int",
	"varint16":  "int16",
	"varint32":  "int32",
	"varint64":  "int64",
	"varuint":   "uint",
	"varsize":   "uint",
	"varuint16": "uint16",
	"varuint32": "uint32",
	"varuint64": "uint64",

	"bool": "bool",

	"string": "string",

	"float16": "float32",
	"float32": "float32",
	"float64": "float64",

	"extern": "any",
	"bytes":  "any",
}

Functions

func Add

func Add(op1, op2 int) int

func DoNotFormatSource added in v0.3.0

func DoNotFormatSource(opts *options)

DoNotFormatSource indicates generate Go source should not be formatted

func EmitSQLSupport added in v0.3.0

func EmitSQLSupport(opt *options)

EmitSQLSupport tells the generator to produce support for storing enum types in a SQL database.

func ExpressionToGoString

func ExpressionToGoString(scope ast.Scope, expression *ast.Expression) string

func Generate

func Generate(m *model.Model, rootPath, rootPackage, outputPackage string, flags ...Option) error

func GetTypeParameter

func GetTypeParameter(pkg *ast.Package, typ *ast.TypeReference) ([]*ast.Parameter, error)

func GoArrayTraits

func GoArrayTraits(scope ast.Scope, typ *ast.TypeReference) (string, error)

func GoExpression

func GoExpression(scope ast.Scope, expression *ast.Expression) string

func GoGetAllImports

func GoGetAllImports(pkg *ast.Package) []string

GoGetAllImports collects a list of all imports (direct and indirect) of a package. This is needed to first generate a full import list, out of which unused items will later be erased

func GoNativeType

func GoNativeType(pkg *ast.Package, typ *ast.TypeReference) (*ast.OriginalTypeReference, error)

func GoPackageAlias

func GoPackageAlias(pkg string) string

func GoPackageName

func GoPackageName(pkg string) string

func GoType

func GoType(scope ast.Scope, typ *ast.TypeReference) (string, error)

func HasIndexOperators added in v0.7.0

func HasIndexOperators(typeRef *ast.TypeReference) bool

func IdentifierToGoString

func IdentifierToGoString(scope ast.Scope, expression *ast.Expression) string

func IsDeltaPackable added in v0.2.6

func IsDeltaPackable(scope ast.Scope, typ *ast.TypeReference) (bool, error)

func StripImports

func StripImports(code []byte) ([]byte, error)

StripImports searches a *.go file for the import section, and checks if the imports are used.

Types

type Option added in v0.3.0

type Option func(opts *options)

Option sets a configuration option

type PathLengthLimiter added in v0.6.1

type PathLengthLimiter struct {
	MaxPathLength int
}

PathLengthLimiter indicates that generated source file paths should be clipped to the given length

func (PathLengthLimiter) LimitPathLength added in v0.6.1

func (limiter PathLengthLimiter) LimitPathLength(opts *options)

Jump to

Keyboard shortcuts

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