generator

package
v0.0.0-...-7625c6f Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NameRelativeTo

func NameRelativeTo(pkg *types.Package) types.Qualifier

NameRelativeTo is the same as types.Relative to, but use the (shorter) package name instead of path.

func Origin

func Origin(ty analysis.Type) string

Origin return the file where the type is defined, suitable to be included as comment.

func SQLTableName

func SQLTableName(name sql.TableName) string

SQLTableName uses a familiar SQL convention for table names, shared by generator/sql and generator/go/sqlcrud

func ToLowerFirst

func ToLowerFirst(str string) string

func ToSnakeCase

func ToSnakeCase(str string) string

func WriteDeclarations

func WriteDeclarations(decls []Declaration) string

WriteDeclarations remove duplicates and aggregate the declarations, sorting them by ID

Types

type Cache

type Cache map[*types.Named]bool

Cache is a cache used to handled recursive types.

func (Cache) Check

func (c Cache) Check(typ analysis.Type) bool

Check returns `true` is `typ` is already in the cache, udpating it if not. Non named types are ignored.

type Declaration

type Declaration struct {
	ID       string // uniquely identifies the item, used to avoid duplicated declarations
	Content  string // actual code to write
	Priority bool   // if true, the declaration is written at the begining of the file
}

Declaration is a top level declaration to write to the generated file.

type Format

type Format uint8
const (
	NoFormat Format = iota
	Go
	Dart
	TypeScript
	Psql
)

type Formatters

type Formatters struct {
	// contains filtered or unexported fields
}

Formatters provides format commands for Go, Dart, TypeScript and SQL. The zero value is a ready to use cache.

func (*Formatters) FormatFile

func (fr *Formatters) FormatFile(format Format, filename string) error

FormatFile format `filename`, if a formatter for `format` is found. It returns an error if the command failed, not if no formatter is found.

Directories

Path Synopsis
Package implements a code generator outputting Dart code for type definitions and JSON routines.
Package implements a code generator outputting Dart code for type definitions and JSON routines.
go
gounions
Package gounions generate JSON wrapper code for union types and types using them
Package gounions generate JSON wrapper code for union types and types using them
sqlcrud
Package sqlcrud generate Go functions to read and write from a DB defined using the conventions from generator/sql
Package sqlcrud generate Go functions to read and write from a DB defined using the conventions from generator/sql
Package typescript generates code for TS type definitions and http calls using the Axios library
Package typescript generates code for TS type definitions and http calls using the Axios library

Jump to

Keyboard shortcuts

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