Go
Go loader guide.
API
Data
func Data() *ProtobufMessage
Get the internal protobuf message data.
Map
func GetN(k1 KEY1, k2 KEY2...) (*MapValueType, error)
Get the Nth-level map value. Be aware that only applies to each level message’s first map field.
OrderedMap
Prerequisite: You need to set metasheet option
OrderedMaptotrue.
func GetOrderedMapN(k1 KEY1, k2 KEY2...) (*OrderedMapValueType, error)
Get the Nth-level ordered map value. Be aware that only applies to each level message’s first map field.
Index
Prerequisite: You need to set metatsheet option
Indexappropriately.
If index name is Chapter, then the accessers are:
- func FindChapterMap() *Index_ChapterMap: Gets the whole hash map.
- func FindChapter(k1 KEY1, k2 KEY2...) []*ParentTypeFinds values by key. One key may correspond to multiple values, which are returned by a slice.
- func FindFirstChapter(k1 KEY1, k2 KEY2...) *ParentType: Finds the first value by key.
OrderedIndex
Prerequisite: You need to set metatsheet option
OrderedIndexappropriately.
If ordered index name is Chapter, then the accessers are:
- func FindChapterMap() *OrderedIndex_ChapterMap: Gets the whole ordered map.
- func FindChapter(k1 KEY1, k2 KEY2...) []*ParentTypeFinds values by key. One key may correspond to multiple values, which are returned by a slice.
- func FindFirstChapter(k1 KEY1, k2 KEY2...) *ParentType: Finds the first value by key.
Custom messager
If the built-in APIs are not sufficient for your business logic, then you can add a custom messager, where you can write preprocess logic based on loaded config objects.
Example: go-tableau-loader/customconf
custom_xxx_conf.go:
type CustomXXXConf struct {
    tableau.UnimplementedMessager
    // TODO: add custom data fields.
}
func (x *CustomItemConf) Name() string {
    return "CustomXXXConf"
}
func (x *CustomItemConf) ProcessAfterLoadAll(hub *tableau.Hub) error {
    // TODO: implement here.
    return nil
}
func init() {
    tableau.Register(func() tableau.Messager {
        return new(CustomXXXConf)
    })
}
Plugin: protoc-gen-go-tableau-loader
An example to use this protoc plugin: go-tableau-loader/gen.sh.
Full example
See go-tableau-loader.