Documentation ¶
Overview ¶
Package enum 提供对枚举方法的生成
枚举值需要 MarshalText 和 String 等方法,其代码格式基本相同。 当前包提供了自动生成这些方法的方便途径。
用户需要自定义枚举类型和枚举值,当前包只提供了对各类方法的生成。 用户可以采用当前包中的 make_state.go 的方式生成,也可以采用 cmd/enums 命令行生成。
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var StateRule = web.NewRuleFunc(locales.InvalidValue, StateValidator)
Functions ¶
func StateValidator ¶
Types ¶
type Enum ¶
type Enum struct { Name string // 类型名 Receiver string // 方法的接收名 Fields []string // 枚举名称,每个名称前会去除类型名前缀 // contains filtered or unexported fields }
Enum 定义枚举类型
type State ¶
type State int8
State 测试用
func (State) MarshalText ¶
MarshalText encoding.TextMarshaler
func (*State) UnmarshalText ¶
UnmarshalText encoding.TextUnmarshaler
Click to show internal directories.
Click to hide internal directories.