gml

command module
v0.0.0-...-bb94247 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: MIT Imports: 13 Imported by: 0

README

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,
	}
)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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