loader

package
v0.0.0-...-e56ea29 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileName

func FileName(p string) string

func FileNameFromTypeName

func FileNameFromTypeName(input, output, typename string) string

func IsFieldExported

func IsFieldExported(name string) bool

func LowerFirst

func LowerFirst(s string) string

func New

func New(fn Generator) error

func NewStructFields

func NewStructFields(structType *types.Struct) (map[string]StructField, error)

func UpperCommonInitialism

func UpperCommonInitialism(s string) string

func UpperFirst

func UpperFirst(s string) string

func Walk

func Walk(visitor Visitor, T types.Type) bool

Types

type Generator

type Generator func(opt Option) error

type Option

type Option struct {
	In      string
	Out     string
	PkgName string
	PkgPath string
	Prefix  string
	Prune   bool
	Items   []OptionItem
}

type OptionItem

type OptionItem struct {
	Name string
	Type types.Type
	Path string
}

type StructField

type StructField struct {
	// Name of the struct field.
	Name string `example:"Name"`

	// Useful when the output directory doesn't match the existing ones.
	PkgPath string `example:"github.com/alextanhongpin/go-codegen/test"`
	PkgName string `example:"test"`

	Exported bool `example:"true"`

	// Stores the original position of the field in the struct.
	Ordinal int

	Tag  *Tag `example:"get:'Renamed'"` // To ignore getter.
	Type types.Type
}

StructField for the example below.

type Foo struct {
 Name sql.NullString `json:"name"
}

type Tag

type Tag struct {
	Name         string
	Skip         bool
	Inline       bool
	InlinePrefix string
}

func NewTag

func NewTag(tag string) (*Tag, error)

type TypeNames

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

func (TypeNames) Items

func (t TypeNames) Items() []string

func (*TypeNames) Set

func (t *TypeNames) Set(val string) error

func (TypeNames) String

func (t TypeNames) String() string

type Visitor

type Visitor interface {
	Visit(T types.Type) bool
}

Jump to

Keyboard shortcuts

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