Documentation ¶
Index ¶
- func SetNamer(n Namer)
- func ToPublicName(name string) string
- func ToPublicSimpleName(name string) string
- func ToSnake(in string) string
- type DefaultNamer
- type File
- type FunctionName
- type FunctionNameList
- type Namer
- type NamespaceNamer
- type Package
- func (p *Package) AddConstant(file, name string, value interface{})
- func (p *Package) AddFunction(file, str, name, def string)
- func (p *Package) AddHeader(file, header string)
- func (p *Package) AddImport(file, name string)
- func (p *Package) AddStruct(file, name, def string)
- func (p *Package) File(name string) (*File, bool)
- func (p *Package) Files() []string
- func (p *Package) HasFunction(file, str, name string) bool
- func (p *Package) HasImport(file, name string) bool
- func (p *Package) HasStruct(file, name string) bool
- func (p *Package) WriteFiles(targetDir string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToPublicName ¶
ToPublicName returns a go-idiomatic public name by using the package's configured namer.
func ToPublicSimpleName ¶
ToPublicSimpleName returns a go-idiomatic public name. The Avro spec specifies names must start with [A-Za-z_] and contain [A-Za-z0-9_]. The golang spec says valid identifiers start with [A-Za-z_] and contain [A-Za-z0-9], but the first character must be [A-Z] for the field to be public.
func ToSnake ¶
ToSnake makes filenames snake-case, taken from https://gist.github.com/elwinar/14e1e897fdbe4d3432e1
Types ¶
type DefaultNamer ¶
type DefaultNamer struct{}
DefaultNamer implements the Namer interface with the backwards-compatible public name generator function.
func (*DefaultNamer) ToPublicName ¶
func (d *DefaultNamer) ToPublicName(name string) string
ToPublicName implements the backwards-compatible name converter in DefaultNamer.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a Go source file in the output package
func (*File) Functions ¶
func (f *File) Functions() []FunctionName
type FunctionName ¶
type FunctionNameList ¶
type FunctionNameList []FunctionName
FunctionNameList implements the Sortable interface for FunctionNames
func (FunctionNameList) Len ¶
func (f FunctionNameList) Len() int
func (FunctionNameList) Less ¶
func (f FunctionNameList) Less(i, j int) bool
Sort functions by the struct to which they're attached first, then the name of the method itself. If the function isn't attached to a struct, put it at the bottom
func (FunctionNameList) Swap ¶
func (f FunctionNameList) Swap(i, j int)
type Namer ¶
type Namer interface { // ToPublicName returns a go-idiomatic public name. The Avro spec // specifies names must start with [A-Za-z_] and contain [A-Za-z0-9_]. // The golang spec says valid identifiers start with [A-Za-z_] and contain // [A-Za-z0-9], but the first character must be [A-Z] for the field to be // public. ToPublicName(name string) string }
Namer is the interface defining a function for converting a name to a go-idiomatic public name.
type NamespaceNamer ¶
type NamespaceNamer struct {
// contains filtered or unexported fields
}
NamespaceNamer is like DefaultNamer but taking into account special tokens so namespaced names can be generated safely.
func NewNamespaceNamer ¶
func NewNamespaceNamer(shortNames bool) *NamespaceNamer
NewNamespaceNamer returns a namespace-aware namer.
func (*NamespaceNamer) ToPublicName ¶
func (n *NamespaceNamer) ToPublicName(name string) string
ToPublicName implements the go-idiomatic public name as in DefaultNamer's struct, but with additional treatment applied in order to remove possible invalid tokens from it. Final string is then converted to camel-case.
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package represents the output package