Skip to content

ganluo960214/gml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gml

generate mapper and list from type and type cost

flags

usage: go:generate gml -type=example -file-name=u_can_set_file_name_or_by_default__-type_gml.go

-type data type
    data type,must be set
-file-name newly generated file name, default as "-type_gml.go"
    file name of the generated file

usage

go get -u github.com/ganluo960214/gml

example:

package main

//go:generate gml -type=example -file-name=u_can_set_file_name_or_by_default__-type_gml.go
type example byte

const (
	ErrCode200 example = 0 // request ok
	ErrCode404 example = 1 // request not found
	ErrCode500 example = 2 // request failed
)

run blow command

go generate

then it will generate file(example_gml.go)

// Code generated by "gml -type=example"; DO NOT EDIT.

package main

var (
	exampleMapper = map[example]string{ 
		ErrCode200:"request ok",ErrCode404:"request not found",ErrCode500:"request failed",
	}
	exampleList = []example{
		ErrCode200,ErrCode404,ErrCode500,
	}
)

About

generate mapper and list from cost

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages