Documentation ¶
Overview ¶
Package codegen generates Go, Protobuf, Flatbuffers, TypeScript, etc. code.
Index ¶
- func EncloseBT(s string) string
- func SkipWS(str ...interface{}) []byte
- type FormatError
- type Go
- func (g *Go) AddImport(importPath, packageName string)
- func (g *Go) AddImports(importPaths ...string)
- func (g *Go) AddInitf(stmt string, a ...interface{})
- func (g *Go) C(comments ...interface{})
- func (g *Go) GenerateFile(w io.Writer) error
- func (g *Go) In()
- func (g *Go) Out()
- func (g *Go) P(str ...interface{})
- func (g *Go) Pln(str ...interface{})
- func (g *Go) WriteConstants(lines ...string)
- type Proto
- func (g *Proto) AddImport(importPath, packageName string)
- func (g *Proto) AddImports(importPaths ...string)
- func (g *Proto) AddOptions(nameRawValue ...string)
- func (g *Proto) C(comments ...interface{})
- func (g *Proto) GenerateFile(w io.Writer) error
- func (g *Proto) In()
- func (g *Proto) Out()
- func (g *Proto) P(str ...interface{})
- func (g *Proto) Pln(str ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FormatError ¶
type FormatError struct { Code string // contains filtered or unexported fields }
FormatError gets returned when generating the source code in case gofmt or any equal other program for a language can't run the formatting.
func (*FormatError) ErrorKind ¶
func (*FormatError) ErrorKind() errors.Kind
type Go ¶
type Go struct { BuildTags []string // each entry is one line // contains filtered or unexported fields }
func (*Go) AddImport ¶
func (g *Go) AddImport(importPath, packageName string)
AddImport adds a new import path. importPath required and packageName optional.
func (*Go) AddImports ¶
func (g *Go) AddImports(importPaths ...string)
AddImports adds multiple import paths at once. They all must have unique base names.
func (*Go) AddInitf ¶
AddInitf stores the given statement to be printed inside the file's init function. The statement is given as a format specifier and arguments.
func (*Go) C ¶
func (g *Go) C(comments ...interface{})
Writes a multiline comment and formats it to a max width of 80 chars. It adds automatically the comment prefix `//`. It converts all types to string, if it can't it panics. If the first argument is a boolean and true, the subsequent data gets printed, otherwise not.
func (*Go) P ¶
func (g *Go) P(str ...interface{})
P same as Pln but without the line break at the end.
func (*Go) Pln ¶
func (g *Go) Pln(str ...interface{})
Pln prints the arguments to the generated output. It tries to convert all kind of types to a string. It adds a line break at the end IF there are strs to print. If the first argument is a boolean and true, the subsequent data gets printed, otherwise not.
func (*Go) WriteConstants ¶
WriteConstants add a const () declaration to the current position in the buffer. A line includes the const name equal value.
type Proto ¶
type Proto struct {
// contains filtered or unexported fields
}
func (*Proto) AddImport ¶
func (g *Proto) AddImport(importPath, packageName string)
AddImport adds a new import path. importPath required and packageName optional.
func (*Proto) AddImports ¶
func (g *Proto) AddImports(importPaths ...string)
AddImports adds multiple import paths at once. They all must have unique base names.
func (*Proto) AddOptions ¶
func (*Proto) C ¶
func (g *Proto) C(comments ...interface{})
Writes a multiline comment and formats it to a max width of 80 chars. It adds automatically the comment prefix `//`. It converts all types to string, if it can't it panics. If the first argument is a boolean and true, the subsequent data gets printed, otherwise not.
func (*Proto) P ¶
func (g *Proto) P(str ...interface{})
P same as Pln but without the line break at the end.
func (*Proto) Pln ¶
func (g *Proto) Pln(str ...interface{})
Pln prints the arguments to the generated output. It tries to convert all kind of types to a string. It adds a line break at the end IF there are strs to print. If the first argument is a boolean and true, the subsequent data gets printed, otherwise not.