From b7d4e2e11ef5474b3ea103c221e0719ec12ba745 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 15 Jan 2024 01:58:06 +0300 Subject: [PATCH] fixup conditions Signed-off-by: Vasiliy Tolstov --- env.go | 8 ++++++++ go.mod | 6 ++++-- go.sum | 6 ++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/env.go b/env.go index c2b7514..f63f240 100644 --- a/env.go +++ b/env.go @@ -40,6 +40,10 @@ func (c *envConfig) Init(opts ...config.Option) error { } func (c *envConfig) Load(ctx context.Context, opts ...config.LoadOption) 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 } @@ -316,6 +320,10 @@ func fillValues(ctx context.Context, valueOf reflect.Value, structTag string) er } func (c *envConfig) Save(ctx context.Context, opts ...config.SaveOption) 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 9e308ad..d06435f 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,8 @@ module go.unistack.org/micro-config-env/v3 go 1.18 require ( - github.com/imdario/mergo v0.3.13 - go.unistack.org/micro/v3 v3.10.16 + github.com/imdario/mergo v0.3.16 + go.unistack.org/micro/v3 v3.10.36 ) + +require github.com/google/uuid v1.5.0 // indirect diff --git a/go.sum b/go.sum index 8ff5437..9a5e3af 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,15 @@ +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.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= +github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/silas/dag v0.0.0-20211117232152-9d50aa809f35/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I= go.unistack.org/micro/v3 v3.10.16 h1:2er/SKKYbV60M+UuJM4eYCF0MZYAIq/yNUrAbTfgq8Q= go.unistack.org/micro/v3 v3.10.16/go.mod h1:uMAc0U/x7dmtICCrblGf0ZLgYegu3VwQAquu+OFCw1Q= +go.unistack.org/micro/v3 v3.10.36 h1:+XPhpguDC0HldSePp5TODdMJ06+IUy1AQkYN7ub84DA= +go.unistack.org/micro/v3 v3.10.36/go.mod h1:eUgtvbtiiz6te93m0ZdmoecbitWwjdBmmr84srmEIKA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=