enum:用于golang的枚举生成器
介绍
枚举是生成枚举结构的工具
安装
go install github.com/Natata/enum
如何使用
写枚举文件
文件格式
type:
[int|string]
name:
[package name]
list:
[enum element] = [value]
文件名无关紧要
产生enum.go
enum -fp=exam.enum
例子
整数枚举
type:
int
name:
direction
list:
West = 0
east = 1
North = 2
South = 3
结果:
package direction
// Alias hide the real type of the enum
// and users can use it to define the var