codegen

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 14 Imported by: 6

README

codegen

Personal code generation tools. YMMV

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func L added in v1.0.2

func L(dst io.Writer, s string, args ...interface{})

L writes a line, PREFIXED with a single new line ('\n') character

func LL added in v1.0.2

func LL(dst io.Writer, s string, args ...interface{})

LL writes a line, PREFIXED with two new line ('\n') characters

func R added in v1.0.2

func R(dst io.Writer, s string, args ...interface{})

R is a short hand for fmt.Fprintf(...)

func RegisterZeroVal added in v1.0.3

func RegisterZeroVal(typ, val string)

func Write

func Write(dst io.Writer, src io.Reader, options ...Option) error

func WriteFile

func WriteFile(filename string, src io.Reader, options ...Option) error

func WriteImports

func WriteImports(dst io.Writer, pkgs ...ImportPkg) error

func ZeroVal added in v1.0.3

func ZeroVal(typ string) string

Types

type CodeFormatError

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

func (CodeFormatError) Error

func (err CodeFormatError) Error() string

func (CodeFormatError) Source

func (err CodeFormatError) Source() string

Returns the source code with line numbers

type ConstantField added in v1.0.3

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

func (*ConstantField) Bool added in v1.0.4

func (f *ConstantField) Bool(s string) bool

func (*ConstantField) GetterMethod added in v1.0.3

func (f *ConstantField) GetterMethod(exported bool) string

func (*ConstantField) IsConstant added in v1.0.3

func (f *ConstantField) IsConstant() bool

func (*ConstantField) IsRequired added in v1.0.3

func (f *ConstantField) IsRequired() bool

func (*ConstantField) JSON added in v1.0.3

func (f *ConstantField) JSON() string

func (*ConstantField) MustBool added in v1.0.4

func (f *ConstantField) MustBool(s string) bool

func (*ConstantField) MustString added in v1.0.4

func (f *ConstantField) MustString(s string) string

func (*ConstantField) Organize added in v1.0.3

func (f *ConstantField) Organize()

func (*ConstantField) SkipMethod added in v1.0.3

func (f *ConstantField) SkipMethod() bool

func (*ConstantField) String added in v1.0.4

func (f *ConstantField) String(s string) string

func (*ConstantField) Type added in v1.0.3

func (f *ConstantField) Type() string

func (*ConstantField) UnmarshalJSON added in v1.0.3

func (f *ConstantField) UnmarshalJSON(data []byte) error

func (*ConstantField) Value added in v1.0.3

func (f *ConstantField) Value() interface{}

type Field added in v1.0.3

type Field interface {
	Organize()

	SkipMethod() bool

	// Name of the field. Can be exported or not exported
	Name(bool) string
	// The Go type
	Type() string

	// The JSON key used
	JSON() string

	GetterMethod(bool) string

	Comment() string

	Extra(string) (interface{}, bool)

	IsRequired() bool
	IsConstant() bool

	Bool(string) bool
	MustBool(string) bool
	String(string) string
	MustString(string) string
}

type FieldList added in v1.0.3

type FieldList []Field

func (*FieldList) UnmarshalJSON added in v1.0.3

func (l *FieldList) UnmarshalJSON(data []byte) error

type ImportPkg added in v1.0.4

type ImportPkg struct {
	Alias string
	URL   string
}

type Object added in v1.0.3

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

func (*Object) AddField added in v1.0.3

func (o *Object) AddField(f Field)

func (*Object) ArrayOf added in v1.0.3

func (o *Object) ArrayOf() string

func (*Object) Bool added in v1.0.4

func (o *Object) Bool(name string) bool

Returns the value of field `name` as a boolean

func (*Object) Comment added in v1.0.3

func (b *Object) Comment() string

func (*Object) Extra added in v1.0.3

func (b *Object) Extra(s string) (interface{}, bool)

func (*Object) Fields added in v1.0.3

func (o *Object) Fields() []Field

func (*Object) Initialize added in v1.0.3

func (b *Object) Initialize()

func (*Object) MustBool added in v1.0.4

func (o *Object) MustBool(name string) bool

func (*Object) MustString added in v1.0.4

func (o *Object) MustString(name string) string

func (*Object) Name added in v1.0.3

func (b *Object) Name(exported bool) string

func (*Object) ObjectOf added in v1.0.3

func (o *Object) ObjectOf() string

func (*Object) Organize added in v1.0.3

func (o *Object) Organize()

func (*Object) String added in v1.0.4

func (o *Object) String(name string) string

Returns the value of field `name` as a string. Returns empty value if the object stored in the field is not a string

func (*Object) UnmarshalJSON added in v1.0.3

func (o *Object) UnmarshalJSON(data []byte) error

type Option

type Option = option.Interface

func WithFormatCode

func WithFormatCode(b bool) Option

func WithLineNumber

func WithLineNumber(b bool) Option

type Output added in v1.0.2

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

func NewOutput added in v1.0.2

func NewOutput(dst io.Writer) *Output

func (*Output) L added in v1.0.2

func (o *Output) L(s string, args ...interface{})

func (*Output) LL added in v1.0.2

func (o *Output) LL(s string, args ...interface{})

func (*Output) R added in v1.0.2

func (o *Output) R(s string, args ...interface{})

func (*Output) Write added in v1.0.2

func (o *Output) Write(dst io.Writer, options ...Option) error

func (*Output) WriteFile added in v1.0.2

func (o *Output) WriteFile(fn string, options ...Option) error

func (*Output) WriteImportPkgs added in v1.0.4

func (o *Output) WriteImportPkgs(pkgs ...ImportPkg) error

func (*Output) WriteImports added in v1.0.2

func (o *Output) WriteImports(urls ...string) error

func (*Output) WritePackage added in v1.0.4

func (o *Output) WritePackage(s string, args ...interface{})

Jump to

Keyboard shortcuts

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