Documentation
¶
Index ¶
- Constants
- func GeneratedFileName(fname string) string
- func GetModDir(pkgDir string) (string, error)
- func RebasePath(base, newBase, file string) (string, error)
- func StripComments(groups []*ast.CommentGroup) []*ast.CommentGroup
- func StripModule(modPath string, needTests bool) (string, error)
- func StripPackage(pkgDir string, needTests bool) (tmpModDir string, tmpPkgDir string, err error)
- func WithDisableFormatting(opt *fileEmitOptions)
- func WithIgnoreGenerated(opt *pkgParserOptions)
- func WithParseTests(opt *pkgParserOptions)
- type Array
- type Bool
- type ByteArray
- type CommentsByIdent
- type Custom
- type Decl
- type DefType
- type Dumb
- type File
- type FileEmitOptionsFunc
- type FilesByPath
- type Float
- type Integer
- type Map
- type Parser
- type ParserOptionsFunc
- type Pointer
- type Slice
- type StringOrBytes
- type Struct
- type StructField
- type StructLiteral
- type Type
Constants ¶
View Source
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" )
View Source
const TmpDirPrefix = "iprotogen-"
Variables ¶
This section is empty.
Functions ¶
func GeneratedFileName ¶
func GetModDir ¶
GetModDir returns the outermost module directory containing specified package directory
func RebasePath ¶
func StripComments ¶
func StripComments(groups []*ast.CommentGroup) []*ast.CommentGroup
StripComments keeps:
- directives
- iprotogen banner
All other comments are removed.
func StripModule ¶
StripModule copies the module to a temporary location preserving only:
- go.mod and go.sum files
- all imports
- all type and const declarations
- all methods (replacing func bodies with a bare return or an empty block depending on values returned)
- all funcs named main (regardless of their params, bodies are stripped too)
- all comments on these entities
Anything other (e.g. vars, non-method funcs) is removed.
If a directory was created successfully it is returned always, even in the case of an error.
func StripPackage ¶
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. When decoding, False byte is decoded as false, and anything else as true (not only the True byte)
type ByteArray ¶
func (ByteArray) EmitMarshaler ¶
type CommentsByIdent ¶
type CommentsByIdent struct {
// contains filtered or unexported fields
}
func (*CommentsByIdent) FromFile ¶
func (cbi *CommentsByIdent) FromFile(fset *token.FileSet, f *ast.File)
func (*CommentsByIdent) FromTypesInfo ¶
func (cbi *CommentsByIdent) FromTypesInfo(fset *token.FileSet, ti *types.Info)
type Custom ¶
type Custom struct {
// contains filtered or unexported fields
}
func (Custom) EmitMarshaler ¶
type DefType ¶
type DefType struct {
// contains filtered or unexported fields
}
DefType describes a defined type
type File ¶
type FileEmitOptionsFunc ¶
type FileEmitOptionsFunc func(*fileEmitOptions)
type FilesByPath ¶
type Integer ¶
func (Integer) EmitMarshaler ¶
type Map ¶
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(pkgName string) (FilesByPath, error)
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 ¶
Click to show internal directories.
Click to hide internal directories.