diff --git a/go.mod b/go.mod index 896d92f..cbd946b 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,16 @@ module go.unistack.org/micro-config-service/v4 -go 1.20 +go 1.21 + +toolchain go1.23.4 require ( - dario.cat/mergo v1.0.0 + dario.cat/mergo v1.0.1 go.unistack.org/micro/v4 v4.0.17 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.35.2 ) require ( - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.6.0 // indirect ) diff --git a/go.sum b/go.sum index c6b4fc5..a8f9de1 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,10 @@ -dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= -dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= go.unistack.org/micro/v4 v4.0.17 h1:mF7uM+J4ILdG+1fcwzKYCwDlxhdbF/e1WnGzKKLnIXc= go.unistack.org/micro/v4 v4.0.17/go.mod h1:ZDgU9931vm2l7X6RN/6UuwRIVp24GRdmQ7dKmegArk4= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/service.go b/service.go index 99448f8..bdfee21 100644 --- a/service.go +++ b/service.go @@ -28,12 +28,15 @@ func (c *serviceConfig) Options() config.Options { } func (c *serviceConfig) Init(opts ...options.Option) error { - if err := config.DefaultBeforeInit(c.opts.Context, c); err != nil && !c.opts.AllowFail { + var err error + if err = config.DefaultBeforeInit(c.opts.Context, c); err != nil && !c.opts.AllowFail { return err } for _, o := range opts { - o(&c.opts) + if err = o(&c.opts); err != nil { + return err + } } var cli client.Client @@ -47,12 +50,12 @@ func (c *serviceConfig) Init(opts ...options.Option) error { } if cli == nil { - err := fmt.Errorf("missing client option") + err = fmt.Errorf("missing client option") if !c.opts.AllowFail { return err } - if err := config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail { + if err = config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail { return err } @@ -60,12 +63,12 @@ func (c *serviceConfig) Init(opts ...options.Option) error { } if c.service == "" { - err := fmt.Errorf("missing Service option") + err = fmt.Errorf("missing Service option") if !c.opts.AllowFail { return err } - if err := config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail { + if err = config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail { return err } @@ -74,7 +77,7 @@ func (c *serviceConfig) Init(opts ...options.Option) error { c.client = pbmicro.NewConfigServiceClient(c.service, cli) - if err := config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail { + if err = config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail { return err }