Documentation
¶
Index ¶
- Constants
- func GeneratedFileName(fname string) string
- func WithDisableFormatting(opt *fileEmitOptions)
- func WithIgnoreGenerated(opt *pkgParserOptions)
- func WithParseTests(opt *pkgParserOptions)
- type Array
- type Bool
- type ByteArray
- type Custom
- type Decl
- type Dumb
- type File
- type FileEmitOptionsFunc
- type FilesByPath
- type Float
- type Integer
- type Map
- type OptionalNull
- type OptionalPointer
- type Parser
- type ParserOptionsFunc
- type Pointer
- type Slice
- type StringOrBytes
- type Struct
- type StructField
- type StructLiteral
- type TimeUnixNanoI64
- type TimeUnixU32
- type Type
Constants ¶
const ( // IProtoDirective - generate [iproto.MarshalerUnmarshaler] implementation for types marked by this special comment. IProtoDirective = "//adv:iproto:" // IProtoTag - struct tag for overriding the field's representation IProtoTag = "iproto" )
Variables ¶
This section is empty.
Functions ¶
func GeneratedFileName ¶
func WithDisableFormatting ¶ added in v0.0.11
func WithDisableFormatting(opt *fileEmitOptions)
func WithIgnoreGenerated ¶ added in v0.0.11
func WithIgnoreGenerated(opt *pkgParserOptions)
func WithParseTests ¶ added in v0.0.11
func WithParseTests(opt *pkgParserOptions)
Types ¶
type Array ¶
func (Array) EmitMarshaler ¶
type Bool ¶
Bool represents a value with an underlying type bool. TypeExpr is the Go type expression (e.g. identBool for bool, or a defined type like MyBool). When decoding, False byte is decoded as false, and anything else as true (not only the True byte).
type ByteArray ¶
func (ByteArray) EmitMarshaler ¶
type Custom ¶
type Custom struct {
// contains filtered or unexported fields
}
func (Custom) EmitMarshaler ¶
type File ¶
type FileEmitOptionsFunc ¶
type FileEmitOptionsFunc func(*fileEmitOptions)
type FilesByPath ¶
func (FilesByPath) Get ¶
func (fbp FilesByPath) Get(filePath string, pkg *typeparser.Package, directives string) *File
type Integer ¶
func (Integer) EmitMarshaler ¶
type Map ¶
type OptionalNull ¶ added in v0.0.15
type OptionalNull struct {
Type Type // inner type for the value field
ValueField *ast.Ident // field name containing the value (e.g. "String", "Int64", "V")
}
OptionalNull wraps a sql.Null* type with a presence byte. Marshal: if .Valid is false, writes 0; otherwise writes 1 followed by the encoded value field. Unmarshal: reads presence byte; if 0, sets Valid=false; if 1, sets Valid=true and reads value.
func (OptionalNull) EmitMarshaler ¶ added in v0.0.15
func (OptionalNull) EmitUnmarshaler ¶ added in v0.0.15
type OptionalPointer ¶ added in v0.0.15
type OptionalPointer struct {
Type Type // inner type (what the pointer points to)
TypeExpr ast.Expr // the type being pointed to
}
OptionalPointer wraps a pointer type with a presence byte. Marshal: if pointer is nil, writes 0; otherwise writes 1 followed by the value. Unmarshal: reads presence byte; if 0, sets nil; if 1, allocates and reads value.
func (OptionalPointer) EmitMarshaler ¶ added in v0.0.15
func (OptionalPointer) EmitUnmarshaler ¶ added in v0.0.15
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewParser ¶
func NewParser(optFuncs ...ParserOptionsFunc) (*Parser, error)
func (*Parser) ParsePackage ¶
func (p *Parser) ParsePackage(pattern string) (FilesByPath, error)
ParsePackage extracts the iproto type descriptions of a package. The pattern is a directory (absolute or starting with "."), or an import path resolved against the module containing the working directory; a "/..." suffix descends into subpackages. The package only has to parse: function bodies are ignored, and declarations without an iproto directive may be arbitrarily broken.
type ParserOptionsFunc ¶
type ParserOptionsFunc func(*pkgParserOptions)
func WithBuildFlag ¶ added in v0.0.11
func WithBuildFlag(flag string) ParserOptionsFunc
func WithModuleDir ¶ added in v0.0.11
func WithModuleDir(dir string) ParserOptionsFunc
func WithOnlyFile ¶ added in v0.0.11
func WithOnlyFile(fname string) ParserOptionsFunc
type Pointer ¶
func (Pointer) EmitMarshaler ¶
type Slice ¶
type StructField ¶
type StructLiteral ¶
type StructLiteral struct {
Fields []StructField
TypeExpr ast.Expr
}
StructLiteral is used for map keys and values
func (StructLiteral) EmitMarshaler ¶
func (StructLiteral) EmitUnmarshaler ¶
type TimeUnixNanoI64 ¶ added in v0.0.14
type TimeUnixNanoI64 struct{}
TimeUnixNanoI64 serializes time.Time as nanoseconds since the Unix epoch in int64. Range: 1677-09-21T00:12:43Z to 2262-04-11T23:47:16Z.
func (TimeUnixNanoI64) EmitMarshaler ¶ added in v0.0.14
func (TimeUnixNanoI64) EmitUnmarshaler ¶ added in v0.0.14
type TimeUnixU32 ¶ added in v0.0.14
type TimeUnixU32 struct{}
TimeUnixU32 serializes time.Time as seconds since the Unix epoch in uint32. Range: 1970-01-01T00:00:00Z to 2106-02-07T06:28:15Z.