From 5fbf98760f2e41fe3c19e06f06407b06f7fb0339 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 15 Jan 2024 01:55:20 +0300 Subject: [PATCH] fixup conditions Signed-off-by: Vasiliy Tolstov --- env.go | 8 ++++++++ go.mod | 7 +++++-- go.sum | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/env.go b/env.go index cb469f4..8705aa2 100644 --- a/env.go +++ b/env.go @@ -41,6 +41,10 @@ func (c *envConfig) Init(opts ...options.Option) error { } func (c *envConfig) Load(ctx context.Context, opts ...options.Option) error { + if c.opts.SkipLoad != nil && c.opts.SkipLoad(ctx, c) { + return nil + } + if err := config.DefaultBeforeLoad(ctx, c); err != nil && !c.opts.AllowFail { return err } @@ -317,6 +321,10 @@ func fillValues(ctx context.Context, valueOf reflect.Value, structTag string) er } func (c *envConfig) Save(ctx context.Context, opts ...options.Option) error { + if c.opts.SkipSave != nil && c.opts.SkipSave(ctx, c) { + return nil + } + options := config.NewSaveOptions(opts...) if err := config.DefaultBeforeSave(ctx, c); err != nil && !c.opts.AllowFail { diff --git a/go.mod b/go.mod index 4b7c6ad..8d715fd 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,10 @@ go 1.20 require ( github.com/imdario/mergo v0.3.16 - go.unistack.org/micro/v4 v4.0.6 + go.unistack.org/micro/v4 v4.0.15 ) -require github.com/google/uuid v1.3.0 // indirect +require ( + dario.cat/mergo v1.0.0 // indirect + github.com/google/uuid v1.5.0 // indirect +) diff --git a/go.sum b/go.sum index 3c2d4cf..c7fbbc2 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,9 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= @@ -7,6 +11,8 @@ go.unistack.org/micro/v4 v4.0.1 h1:xo1IxbVfgh8i0eY0VeYa3cbb13u5n/Mxnp3FOgWD4Jo= go.unistack.org/micro/v4 v4.0.1/go.mod h1:p/J5UcSJjfHsWGT31uKoghQ5rUQZzQJBAFy+Z4+ZVMs= go.unistack.org/micro/v4 v4.0.6 h1:YFWvTh3VwyOd6NHYTQcf47n2TF5+p/EhpnbuBQX3qhk= go.unistack.org/micro/v4 v4.0.6/go.mod h1:bVEYTlPi0EsdgZZt311bIroDg9ict7ky3C87dSCCAGk= +go.unistack.org/micro/v4 v4.0.15 h1:o4++RYX5guVPxfcJpP7VCj2Xr9BPFo6fj4+b5FStdEI= +go.unistack.org/micro/v4 v4.0.15/go.mod h1:ZDgU9931vm2l7X6RN/6UuwRIVp24GRdmQ7dKmegArk4= 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=