generator

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2017 License: MIT Imports: 9 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToPublicName

func ToPublicName(name string) string

ToPublicName returns a go-idiomatic public name

func ToSnake

func ToSnake(in string) string

Make filenames snake-case, taken from https://gist.github.com/elwinar/14e1e897fdbe4d3432e1

Types

type File

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

File represents a Go source file in the output package

func NewFile

func NewFile(name string) *File

func (*File) Functions

func (f *File) Functions() []FunctionName

func (*File) Imports

func (f *File) Imports() []string

func (*File) Structs

func (f *File) Structs() []string

func (*File) WriteFile

func (f *File) WriteFile(pkgName, targetFile string) error
Write the contents of the file:

- imports (all in one block) - struct definitions (alphabetically) - functions (sorted alphabetically by struct to which they're attached, then unattached funcs) TODO: It'd be better to group funcs attached to a struct with the struct definition

type FunctionName

type FunctionName struct {
	// The target struct type, if there is one
	Str string
	// The function name
	Name string
}

type FunctionNameList

type FunctionNameList []FunctionName

Implement 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 Package

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

Represents the output package

func NewPackage

func NewPackage(name string) *Package

func (*Package) AddConstant

func (p *Package) AddConstant(file, name string, value interface{})

func (*Package) AddFunction

func (p *Package) AddFunction(file, str, name, def string)

func (*Package) AddHeader

func (p *Package) AddHeader(file, header string)

func (*Package) AddImport

func (p *Package) AddImport(file, name string)

func (*Package) AddStruct

func (p *Package) AddStruct(file, name, def string)

func (*Package) File

func (p *Package) File(name string) (*File, bool)

func (*Package) Files

func (p *Package) Files() []string

func (*Package) HasFunction

func (p *Package) HasFunction(file, str, name string) bool

func (*Package) HasImport

func (p *Package) HasImport(file, name string) bool

func (*Package) HasStruct

func (p *Package) HasStruct(file, name string) bool

func (*Package) WriteFiles

func (p *Package) WriteFiles(targetDir string) error

Jump to

Keyboard shortcuts

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