enum

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var G = Generater{
	// contains filtered or unexported fields
}

G Generater

Functions

This section is empty.

Types

type Enum

type Enum struct {
	Name  string
	Doc   string
	Items []*Item
}

Enum 枚举类型

func NewEnum

func NewEnum(name string) *Enum

NewEnum todo

func (*Enum) Add

func (e *Enum) Add(i *Item)

Add todo

type Generater

type Generater struct {
	Marshal     bool
	ProtobufExt bool
	// contains filtered or unexported fields
}

Generater 用于生成枚举的生成器

func (*Generater) Generate

func (g *Generater) Generate(file string) ([]byte, error)

Generate 生成文件

type Item

type Item struct {
	Name string // 枚举的名称, 对应常量的名称
	Doc  string // 文档, 常量的文档
}

Item 枚举项 通过获取注释里()中的内容作为自定义参数

func NewItem

func NewItem(name, doc string) *Item

NewItem todo

func (*Item) Show

func (i *Item) Show() string

Show 枚举项显示

type RenderParams

type RenderParams struct {
	PKG       string
	Backquote string
	Enums     *Set
	Marshal   bool
	Stringer  bool
	ValueMap  bool
}

RenderParams 模板渲染需要的参数

func NewRenderParams

func NewRenderParams() *RenderParams

NewRenderParams todo

type Set

type Set struct {
	Items []*Enum
}

Set 枚举集合

func NewEnumSet

func NewEnumSet() *Set

NewEnumSet todo

func (*Set) Add

func (s *Set) Add(i *Enum)

Add 添加一个类型

func (*Set) Get

func (s *Set) Get(name string) *Enum

Get 获取一个枚举类

func (*Set) GetLatest

func (s *Set) GetLatest() *Enum

GetLatest 获取最新一个

func (*Set) Length

func (s *Set) Length() int

Length 长度

Jump to

Keyboard shortcuts

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