manager

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddProto

func AddProto(file string, buf *bytes.Buffer)

func AddRef

func AddRef(filename string, reference map[string]struct{})

func AddTable

func AddTable(file, sheet string, typeOf int, t string, rows [][]string, rules []string)

func AddTableFull added in v1.2.9

func AddTableFull(file, sheet string, typeOf int, t string, rows [][]string, rules []string, feature, table string)

AddTableFull 是 AddTable 的完整版本,额外携带 feature/table 元信息。

file    : 文件名(= 功能名,决定 proto 分桶;保持与旧 key 一致)
sheet   : 原始 sheet 名(保持与 GetTable 的 key 一致)
feature : 功能名(从 xlsx 文件名 @ 前解析;默认 = file)
table   : 表名(从 sheet 名 @ 前解析)

func Clear

func Clear()

Clear resets every manager-global container so that sequential test cases (or repeated runs) start from a clean slate. Maps are re-initialized to empty (not nil) because the various Add* helpers write to them without a nil check.

注意:convertMgr 不在此清理之列——它由 init() 注册基础标量类型 (int32/string/bool 等)的转换器,是静态表而非累积状态,清空会导致 所有基础类型被识别为"未识别的类型"。

func FindExternalMsgDescriptor added in v1.2.6

func FindExternalMsgDescriptor(name string) *desc.MessageDescriptor

FindExternalMsgDescriptor 返回外部 message 的 MessageDescriptor(供数据生成反射用)。

func GetConfig

func GetConfig(name string) *base.Config

func GetConfigList

func GetConfigList() (rets []*base.Config)

func GetConfigMap

func GetConfigMap() map[string]*base.Config

func GetContainerOf added in v1.2.6

func GetContainerOf(name string) int

GetContainerOf 根据类型名前缀判定字段值容器类别。 map[K]V -> ContainerMap;[]... 前缀 -> ContainerArray;其余 -> ContainerSingle。

func GetConvFunc

func GetConvFunc(name string) func(string) interface{}

func GetConvType

func GetConvType(name string) string

func GetEnum

func GetEnum(name string) *base.Enum

func GetEnumList

func GetEnumList() (rets []*base.Enum)

func GetEnumMap

func GetEnumMap() map[string]*base.Enum

func GetIndexMap

func GetIndexMap() (rets []int)

func GetOrNewConfig

func GetOrNewConfig(file, sheet, name, feature, table string) *base.Config

-----config-------

func GetOrNewEnum

func GetOrNewEnum(name string) *base.Enum

-----enum-------

func GetOrNewStruct

func GetOrNewStruct(file, sheet, name, feature, table string) *base.Struct

-----struct-------

func GetProtoList

func GetProtoList() []string

func GetProtoMap

func GetProtoMap() map[string]string

func GetRefList

func GetRefList(file string) []string

func GetStruct

func GetStruct(name string) *base.Struct

func GetStructList

func GetStructList() (rets []*base.Struct)

func GetStructMap

func GetStructMap() map[string]*base.Struct

func GetTable

func GetTable(file, sheet string) *base.Table

func GetTableList

func GetTableList(typeOf int) []*base.Table

func GetTypeOf

func GetTypeOf(name string) int

func GetValueOf

func GetValueOf(name string) int

func IsExternalEnum added in v1.2.6

func IsExternalEnum(name string) bool

func IsExternalMsg added in v1.2.6

func IsExternalMsg(name string) bool

func IsExternalProto added in v1.2.9

func IsExternalProto(key string) bool

IsExternalProto 判断 key 是否来自 -proto-src 外部 proto 载入。 外部 proto 仅用于类型解析,SaveProto 不把它们输出到 -proto 目录。

func LoadExternalProtos added in v1.2.6

func LoadExternalProtos(dirs ...string) error

LoadExternalProtos 加载 -proto-src 目录下所有 .proto 文件:

  1. 读入 protoMgr(key 为相对根路径,如 core/struct.proto,与 import 路径风格一致), 使后续 ParseProto 能统一解析并 cross-link
  2. 预解析每个文件,提取 message/enum 短名注册到 externalMsgMgr/externalEnumMgr

支持多目录(-proto-src 用路径分隔符拼接,Windows 为分号):先加载全部目录的文件, 再统一预解析一次——import 图可能跨目录(如 service 协议 import 主仓 api/proto 的 goone/options),逐目录解析会因依赖尚未加载而失败刷警告。

key 为相对目录根的路径(去掉目录前缀,保证与 proto 内 import 路径一致)。

func NewProto

func NewProto(fileName, name string) *dynamic.Message

NewProto 按 message 名构造 dynamic.Message。 检索策略:

  1. 先在 fileName 对应的 FileDescriptor 上用全限定名查找(内置 struct/config 的常规路径)
  2. 找不到则全局遍历所有 descMap(外部 message 可能定义在任意外部 proto 文件)

func ParseProto

func ParseProto() error

func SplitArrayType added in v1.2.3

func SplitArrayType(name string) (string, int)

func SplitExternalType added in v1.2.6

func SplitExternalType(name string) (short string, ok bool)

SplitExternalType 识别 pb.XXX 外部 proto 引用语法。 命中返回短名 XXX 与 true;否则返回 ok=false。 pb. 是纯语法糖,表示「去外部 proto 注册表检索」。

func SplitMapType added in v1.2.6

func SplitMapType(name string) (key, val string, ok bool)

SplitMapType 解析 map[K]V 形式的字段类型。 命中返回 (K 原始名, V 原始名, true);否则返回 ok=false。 仅识别最外层的 map(不递归,嵌套 map 本期不支持)。 注意:V 是首个 ']' 之后的全部内容(V 不被 ']' 包裹),故不能用 HasSuffix("]")。

Types

type ExternalType added in v1.2.6

type ExternalType struct {
	Name      string
	FullName  string
	ProtoFile string
}

ExternalType 描述一个外部 proto 定义的 message 或 enum。 FullName 是全限定名(如 g1.protocol.Reward),Name 是短名(Reward), ProtoFile 是该类型所在 proto 文件的「相对仓库根路径」(如 proto/core/struct.proto), 用于生成 import 语句。

func GetExternalEnum added in v1.2.6

func GetExternalEnum(name string) *ExternalType

func GetExternalMsg added in v1.2.6

func GetExternalMsg(name string) *ExternalType

type ExtractOptions added in v1.2.3

type ExtractOptions struct {
	AllowDecimal      bool // 是否允许小数点
	AllowLeadingZeros bool // 是否保留前导零
}

选项配置

Jump to

Keyboard shortcuts

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