gen

package
v0.0.0-...-73e874a Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodFind   = "find"
	MethodFilter = "filter"
	MethodMaps   = "maps"
	MethodArray  = "array"
	MethodGet    = "get"
	MethodUniq   = "uniq"
	MethodSort   = "sort"
	MethodEach   = "each"
)
View Source
const (
	GrizzlyCollection = "Collection"
	GrizzlyModel      = "Model"

	CommandReplaceName = "grizzly:replaceName"
	CommandGenerate    = "grizzly:generate"
)
View Source
const GithubRepo = "github.com/matroskin13/grizzly"

Variables

View Source
var PrimitiveTypes = []string{
	"int",
	"int8",
	"int16",
	"int32",
	"int64",
	"uint",
	"uint8",
	"uint16",
	"uint32",
	"uint64",
	"uintptr",
	"string",
	"bool",
	"float64",
	"float32",
}

Functions

func ApplyCommands

func ApplyCommands(node *ast.File, config *GrizzlyConfigCollection) *ast.File

func CheckExistDir

func CheckExistDir(path string) bool

func CheckExistFile

func CheckExistFile(path string) bool

func CreateCollection

func CreateCollection(modelName string, code string, isUpdate bool, savePath string) error

func GenCode

func GenCode(config *GrizzlyConfigCollection, code []byte, isSimple bool) []byte

func GenCollectionCode

func GenCollectionCode(config GrizzlyConfigCollection, isSimple bool) (result string, err error)

func GetCollectionCode

func GetCollectionCode() (result []byte, err error)

func GetCollectionDir

func GetCollectionDir(isDev bool) (string, error)

func GetDefaultMethods

func GetDefaultMethods() []string

func GetGrizzlyCommand

func GetGrizzlyCommand(doc *ast.CommentGroup) map[string]GrizzlyCommand

Return grizzly commands by comments of code. Example:

//grizzly:replaceName GetGrizzly{{.Name}} func GetGrizzly() {}

func GetImportsByMethods

func GetImportsByMethods(methods []string) (imports []string)

func GetMethod

func GetMethod(collectionDir string, method string) (result []byte, err error)

func GetMethodsCode

func GetMethodsCode(methods []string, types []GrizzlyType) (result []byte, err error)

func InjectImports

func InjectImports(code []byte, imports []string) (result []byte)

func InjectTypes

func InjectTypes(node *ast.File, config *GrizzlyConfigCollection)

func IsPropertyMethod

func IsPropertyMethod(method string) bool

func RemovePackage

func RemovePackage(code []byte) []byte

Remove package name

func RemoveType

func RemoveType(node *ast.File, config *GrizzlyConfigCollection)

func ReplaceGrizzlyId

func ReplaceGrizzlyId(code []byte, customType string) []byte

func ReplaceImports

func ReplaceImports(code []byte) []byte

func ReplaceSearchCallback

func ReplaceSearchCallback(code []byte, modelName string) []byte

func SwapTypes

func SwapTypes(node *ast.File, config *GrizzlyConfigCollection)

Replaces grizzly Model and Collection

Types

type GrizzlyCommand

type GrizzlyCommand struct {
	Command string
	Action  string
}

type GrizzlyConfig

type GrizzlyConfig struct {
	Collections []GrizzlyConfigCollection `json:"collections"`
}

func GetConfigByCode

func GetConfigByCode(code []byte) (*GrizzlyConfig, error)

Create config from GO code

type GrizzlyConfigCollection

type GrizzlyConfigCollection struct {
	Name    string            `json:"name"`
	Types   map[string]string `json:"types"`
	Methods []string
	Package string
}

type GrizzlyType

type GrizzlyType struct {
	Name        string
	Value       string
	IsPointer   bool
	IsPrimitive bool
}

func GenerateTypes

func GenerateTypes(configTypes map[string]string) []GrizzlyType

Jump to

Keyboard shortcuts

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