parse

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2018 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Invalid    = Kind(types.Invalid)
	Bool       = Kind(types.Bool)
	Int        = Kind(types.Int)
	Int8       = Kind(types.Int8)
	Int16      = Kind(types.Int16)
	Int32      = Kind(types.Int32)
	Int64      = Kind(types.Int64)
	Uint       = Kind(types.Uint)
	Uint8      = Kind(types.Uint8)
	Uint16     = Kind(types.Uint16)
	Uint32     = Kind(types.Uint32)
	Uint64     = Kind(types.Uint64)
	Float32    = Kind(types.Float32)
	Float64    = Kind(types.Float64)
	Complex64  = Kind(types.Complex64)
	Complex128 = Kind(types.Complex128)
	String     = Kind(types.String)

	Interface = 101
	Map       = 102
	Slice     = 103
	Struct    = 104
)
View Source
const TagKey = "sql"

Variables

View Source
var Debug = false
View Source
var PrintAST = false

Functions

func DevInfo

func DevInfo(format string, args ...interface{})

Types

type Group

type Group struct {
	Owner   string
	Sources []Source
}

type Kind

type Kind types.BasicKind

func (Kind) IsFloat

func (k Kind) IsFloat() bool

func (Kind) IsInteger

func (k Kind) IsInteger() bool

func (Kind) IsShort

func (k Kind) IsShort() bool

func (Kind) IsSimpleType

func (k Kind) IsSimpleType() bool

func (Kind) Token

func (k Kind) Token() string

type LType added in v0.8.0

type LType struct {
	PkgName string // package name (short name)
	Name    string // name of source code type.
}

func (LType) String added in v0.8.0

func (t LType) String() string

type PackageGroup

type PackageGroup struct {
	Pkg   *types.Package
	Files []*ast.File
}

type PackageStore

type PackageStore map[string]PackageGroup

func Parse

func Parse(paths []string) (PackageStore, error)

func ParseGroups

func ParseGroups(fset *token.FileSet, groups ...Group) (PackageStore, error)

func (PackageStore) FindNamed

func (st PackageStore) FindNamed(name LType) *types.Named

func (PackageStore) FindStruct

func (st PackageStore) FindStruct(name LType) (*types.Struct, map[string]Tag)

func (PackageStore) FindTags

func (st PackageStore) FindTags(name LType) Tags

type Source

type Source struct {
	Name string
	In   io.Reader
}

type Tag

type Tag struct {
	Name     string `yaml:"name"`
	Type     string `yaml:"type"`
	Prefixed bool   `yaml:"prefixed"`
	Primary  bool   `yaml:"pk"`
	Auto     bool   `yaml:"auto"`
	Index    string `yaml:"index"`
	Unique   string `yaml:"unique"`
	//Check      string `yaml:"check"` TODO
	ForeignKey string `yaml:"fk"`
	OnUpdate   string `yaml:"onupdate"`
	OnDelete   string `yaml:"ondelete"`
	Size       int    `yaml:"size"`
	Skip       bool   `yaml:"skip"`
	Encode     string `yaml:"encode"`
}

Tag stores the parsed data from the tag string in a struct field.

func ParseTag

func ParseTag(raw string) (*Tag, error)

ParseTag parses a tag string from the struct field and unmarshals into a Tag struct.

func (Tag) ParentPK added in v0.12.0

func (tag Tag) ParentPK() string

func (Tag) ParentTable added in v0.12.0

func (tag Tag) ParentTable() string

type Tags added in v0.8.0

type Tags map[string]Tag

func ReadTagsFile added in v0.8.0

func ReadTagsFile(file string) (Tags, error)

func (Tags) String added in v0.8.0

func (tags Tags) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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