codegen

package
v0.0.0-...-6945508 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	PREFIX_INPUT  = "Input"
	PREFIX_OUTPUT = "Output"

	TokenMethod    = "@method (.*)"
	TokenPath      = "@path (.*)"
	TokenQuery     = "@query (.*)"
	TokenProtected = "@protected"

	TokenNameMethod    = "method"
	TokenNamePath      = "path"
	TokenNameQuery     = "query"
	TokenNameProtected = "protected"

	MethodPOST = "POST"
	MethodGET  = "GET"
)

Variables

This section is empty.

Functions

func MakeInputOutputStructs

func MakeInputOutputStructs(fn *ast.FuncDecl, imps []*ast.ImportSpec, comments []*ast.CommentGroup) (*Struct, *Struct)

func MakeMethod

func MakeMethod(fn *ast.FuncDecl, comments map[string][]string) []string

func MakePattern

func MakePattern(fn *ast.FuncDecl, comments map[string][]string) string

func MakeProtected

func MakeProtected(fn *ast.FuncDecl, comments map[string][]string) bool

func MakeQuery

func MakeQuery(fn *ast.FuncDecl, comments map[string][]string, method []string, path string) []string

func ParsePackage

func ParsePackage(comments []*ast.CommentGroup) *string

func Render

func Render(w io.Writer, tpl string, data interface{}) error

Render method

Types

type ByOrder

type ByOrder []Field

func (ByOrder) Len

func (a ByOrder) Len() int

func (ByOrder) Less

func (a ByOrder) Less(i, j int) bool

func (ByOrder) Swap

func (a ByOrder) Swap(i, j int)

type Field

type Field struct {
	Order int
	Name  string
	Type  string
	Tag   string
}

func (Field) GetOutVarName

func (fld Field) GetOutVarName() string

func (Field) GetTag

func (fld Field) GetTag() string

func (Field) GetVarName

func (fld Field) GetVarName() string

func (Field) GetVarType

func (fld Field) GetVarType() string

func (Field) GetVarValue

func (fld Field) GetVarValue(data map[string]string) (interface{}, error)

type Fields

type Fields map[string]Field

type Func

type Func struct {
	PkgPath   string
	Name      string
	Method    []string
	Protected bool
	Pattern   string
	Query     []string
	In        *Struct
	Out       *Struct
}

func MakeFunc

func MakeFunc(fn *ast.FuncDecl, imps []*ast.ImportSpec, comments []*ast.CommentGroup) *Func

func (Func) GetFullName

func (f Func) GetFullName() string

func (Func) GetHandlerName

func (f Func) GetHandlerName() string

func (Func) GetMethod

func (f Func) GetMethod() []string

func (Func) GetOnlyPkgName

func (f Func) GetOnlyPkgName() string

func (Func) GetPattern

func (f Func) GetPattern() string

func (Func) GetPkgPath

func (f Func) GetPkgPath() string

func (Func) GetProtected

func (f Func) GetProtected() bool

func (Func) GetQuery

func (f Func) GetQuery() []string

type Funcs

type Funcs []Func

type Import

type Import struct {
	Alias string
	Path  string
}

func (Import) GetPathAsAlias

func (i Import) GetPathAsAlias() string

type Imports

type Imports map[string]Import

type Service

type Service struct {
	Import Import
	Funcs  Funcs
}

type Services

type Services []Service

type Struct

type Struct struct {
	Imports Imports
	Name    string
	Fields  Fields
}

func (Struct) GetFieldsSlice

func (s Struct) GetFieldsSlice() []Field

func (Struct) GetName

func (s Struct) GetName() string

type Structs

type Structs map[string]Struct

Directories

Path Synopsis
sub

Jump to

Keyboard shortcuts

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