protoenum

package
v0.12.10 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Identity               = "enum"
	Attribute_Name_Mapping = "mapping"
)

annotation const value

Variables

This section is empty.

Functions

func IntoEnumComment

func IntoEnumComment(pe *protogen.Enum) string

IntoEnumComment generates enum comment if it exists format: @EnumValue[xxx]

Types

type Enum

type Enum struct {
	MessageName string       // 嵌套消息名
	Name        string       // 名称
	Comment     string       // 注释
	Values      []*EnumValue // 枚举项
}

Enum 枚举 NOTE:

如果 MessageName 为空, 表明枚举独立, 枚举类型为 ${{Name}}, 枚举值为 ${{Name}}_${{Value}}
如果 MessageName 为不为空, 表明枚举嵌套在message里, 枚举类型为 ${{MessageName}}_{{Name}}, 枚举值为 ${{MessageName}}_${{Value}}

func IntoEnums

func IntoEnums(nestedMessageName string, protoEnums []*protogen.Enum) []*Enum

IntoEnums generates the errors definitions, excluding the package statement.

func IntoEnumsFromMessage

func IntoEnumsFromMessage(nestedMessageName string, protoMessages []*protogen.Message) []*Enum

IntoEnumsFromMessage generates the errors definitions, excluding the package statement.

type EnumDerive added in v0.12.3

type EnumDerive struct {
	Enabled bool
}

func ParseDeriveEnum added in v0.12.2

func ParseDeriveEnum(s protogen.Comments) (*EnumDerive, protoutil.CommentLines)

type EnumValue

type EnumValue struct {
	Number      int    // 编号
	Value       string // 值,例: Status_Enabled
	CamelValue  string // 驼峰值,例: StatusEnabled
	TrimValue   string // 值截断EnumName前缀,例: Enabled(EnumName=Status)
	Mapping     string // 映射值
	Comment     string // 注释
	IsDuplicate bool   // 是否是副本
}

EnumValue 枚举的枚举项

type EnumValueDerive added in v0.12.3

type EnumValueDerive struct {
	Mapping string
}

func ParseDeriveEnumValue added in v0.12.2

func ParseDeriveEnumValue(s protogen.Comments) (*EnumValueDerive, protoutil.CommentLines)

Jump to

Keyboard shortcuts

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