generator

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

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

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

Documentation

Overview

Package generator provides types and functions for ent generator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	*ast.Field
	Default              string // go code expression for the default value
	Form                 string // go code expression to parse form value (var name is v and returns (value, error))
	SearchFieldTypeName  string // go code expression for SearchDoc typename
	SearchFieldConverter string // go code expression to convert a original ent field tothe serach doc field
	Parser               string // optional field to parse the string value (pkg.Func format)
	IsID                 bool
	IsTimestamp          bool
	IsForm               bool
	IsSearch             bool
	ResetIfMissing       bool
	// contains filtered or unexported fields
}

Field is a type field

func (*Field) FieldName

func (f *Field) FieldName() string

FieldName returns a field name string

func (*Field) FieldNameSnakeCase

func (f *Field) FieldNameSnakeCase() string

FieldNameSnakeCase returns a snakecase of the field name.

func (*Field) GetDefaultExpr

func (f *Field) GetDefaultExpr(v string) string

GetDefaultExpr returns the default value expression for the field.

func (*Field) GetFormExpr

func (f *Field) GetFormExpr() string

GetFormExpr returns a form field expression of the field.

func (*Field) GetSearchFieldTypeName

func (f *Field) GetSearchFieldTypeName() (string, string)

GetSearchFieldType returns a type name string for search of the field.

func (*Field) TypeName

func (f *Field) TypeName() string

TypeName returns a type name string of the field.

type Struct

type Struct struct {
	Package        string
	Type           string
	Kind           string
	Instance       string
	Fields         []*Field
	Dependencies   map[string]string
	IDField        string
	TimestampField string
	IsSearchable   bool
}

Struct is a parsed result of struct to generate a code.

func NewStruct

func NewStruct(typeName string, kindName string) *Struct

NewStruct returns a struct for the type `typeName`

func (*Struct) AddDependency

func (s *Struct) AddDependency(pkg string)

AddDependency adds a dependent package of the struct

func (*Struct) AddDependencyAs

func (s *Struct) AddDependencyAs(pkg string, as string)

AddDependencyAs is like AddDependency with specifiyng the alias name.

func (*Struct) GenSource

func (s *Struct) GenSource(w io.Writer) error

GenSource implements Generator#GenSource

func (*Struct) Inspect

func (s *Struct) Inspect(node ast.Node) bool

Inspect implements Generator#Inspect

Jump to

Keyboard shortcuts

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