IndieGame/config/Table/Tools/Luban/Templates/go-json/tables.sbn
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

29 lines
665 B
Plaintext

{{~if __namespace != ''~}}
package {{__namespace}};
{{~end~}}
type JsonLoader func(string) ([]map[string]interface{}, error)
type {{__name}} struct {
{{~for table in __tables ~}}
{{table.name}} *{{full_name table}}
{{~end~}}
}
func NewTables(loader JsonLoader) (*{{__name}}, error) {
var err error
var buf []map[string]interface{}
tables := &{{__name}}{}
{{~for table in __tables ~}}
if buf, err = loader("{{table.output_data_file}}") ; err != nil {
return nil, err
}
if tables.{{table.name}}, err = New{{full_name table}}(buf) ; err != nil {
return nil, err
}
{{~end~}}
return tables, nil
}