Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/protoc-gen-go-tableau-loader/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type Messager interface {
// GetStats returns stats info.
GetStats() *Stats
// Load fills message from file in the specified directory and format.
Load(dir string, fmt format.Format, options ...load.Option) error
Load(dir string, fmt format.Format, opts *load.MessagerOptions) error
// Store writes message to file in the specified directory and format.
Store(dir string, fmt format.Format, options ...store.Option) error
// processAfterLoad is invoked after this messager loaded.
Expand Down Expand Up @@ -169,7 +169,7 @@ func (x *UnimplementedMessager) GetStats() *Stats {
return &x.Stats
}

func (x *UnimplementedMessager) Load(dir string, format format.Format, options ...load.Option) error {
func (x *UnimplementedMessager) Load(dir string, format format.Format, opts *load.MessagerOptions) error {
return nil
}

Expand Down Expand Up @@ -290,8 +290,10 @@ func (h *Hub) GetMessager(name string) Messager {
// Load fills messages from files in the specified directory and format.
func (h *Hub) Load(dir string, format format.Format, options ...load.Option) error {
messagerMap := h.NewMessagerMap()
opts := load.ParseOptions(options...)
for name, msger := range messagerMap {
if err := msger.Load(dir, format, options...); err != nil {
mopts := load.ParseMessagerOptionsFromOptions(opts, name)
if err := msger.Load(dir, format, mopts); err != nil {
return errors.WithMessagef(err, "failed to load: %v", name)
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/protoc-gen-go-tableau-loader/messager.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ func genMessage(gen *protogen.Plugin, g *protogen.GeneratedFile, message *protog
g.P()

g.P("// Load fills ", messagerName, "'s inner message from file in the specified directory and format.")
g.P("func (x *", messagerName, ") Load(dir string, format ", formatPackage.Ident("Format"), " , options ...", loadPackage.Ident("Option"), ") error {")
g.P("func (x *", messagerName, ") Load(dir string, format ", formatPackage.Ident("Format"), " , opts *", loadPackage.Ident("MessagerOptions"), ") error {")
g.P("start := ", timePackage.Ident("Now"), "()")
g.P("defer func () {")
g.P("x.Stats.Duration = ", timePackage.Ident("Since"), "(start)")
g.P("}()")
g.P("x.data = &", message.GoIdent, "{}")
g.P("err := ", loadPackage.Ident("Load"), "(x.data, dir, format, options...)")
g.P("err := ", loadPackage.Ident("LoadMessagerInDir"), "(x.data, dir, format, opts)")
g.P("if err != nil {")
g.P("return err")
g.P("}")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.10.0
github.com/tableauio/tableau v0.13.1-0.20250729035848-d72aa4ead3c4
github.com/tableauio/tableau v0.13.1-0.20250815085205-2917481cc73f
golang.org/x/exp v0.0.0-20230418202329-0354be287a23
google.golang.org/protobuf v1.34.2
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subchen/go-xmldom v1.1.2 h1:7evI2YqfYYOnuj+PBwyaOZZYjl3iWq35P6KfBUw9jeU=
github.com/subchen/go-xmldom v1.1.2/go.mod h1:6Pg/HuX5/T4Jlj0IPJF1sRxKVoI/rrKP6LIMge9d5/8=
github.com/tableauio/tableau v0.13.1-0.20250729035848-d72aa4ead3c4 h1:4xwjLqGulwJLjo7yr4z8jjbYo37H1X9j92D8aA6EIng=
github.com/tableauio/tableau v0.13.1-0.20250729035848-d72aa4ead3c4/go.mod h1:EitY0lyJa8gP6tBkzWhS2WvYhC8hyWPGXoR4QPQ+Qmw=
github.com/tableauio/tableau v0.13.1-0.20250815085205-2917481cc73f h1:Nf0UX+/p5tzm9c2KyfdqM9oxMb3ZuP5sGr60zK8xmvk=
github.com/tableauio/tableau v0.13.1-0.20250815085205-2917481cc73f/go.mod h1:EitY0lyJa8gP6tBkzWhS2WvYhC8hyWPGXoR4QPQ+Qmw=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 h1:6932x8ltq1w4utjmfMPVj09jdMlkY0aiA6+Skbtl3/c=
Expand Down
8 changes: 4 additions & 4 deletions test/go-tableau-loader/protoconf/loader/hero_conf.pc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions test/go-tableau-loader/protoconf/loader/hub.pc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/go-tableau-loader/protoconf/loader/item_conf.pc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions test/go-tableau-loader/protoconf/loader/patch_conf.pc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions test/go-tableau-loader/protoconf/loader/test_conf.pc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion third_party/_submodules/tableau