From 5f9029c496b9936405563f19902158e9e8867add Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 15 Jan 2024 02:02:50 +0300 Subject: [PATCH] fixup conditions Signed-off-by: Vasiliy Tolstov --- flag.go | 8 ++++++++ go.mod | 7 +++++-- go.sum | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/flag.go b/flag.go index b89a278..904aaca 100644 --- a/flag.go +++ b/flag.go @@ -156,6 +156,10 @@ func (c *flagConfig) Init(opts ...config.Option) error { } func (c *flagConfig) Load(ctx context.Context, opts ...config.LoadOption) error { + if c.opts.SkipLoad != nil && c.opts.SkipLoad(ctx, c) { + return nil + } + options := config.NewLoadOptions(opts...) _ = options @@ -174,6 +178,10 @@ func (c *flagConfig) Load(ctx context.Context, opts ...config.LoadOption) error } func (c *flagConfig) Save(ctx context.Context, opts ...config.SaveOption) error { + if c.opts.SkipSave != nil && c.opts.SkipSave(ctx, c) { + return nil + } + if err := config.DefaultBeforeSave(ctx, c); err != nil && !c.opts.AllowFail { return err } diff --git a/go.mod b/go.mod index 19bf822..5b60c87 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,9 @@ module go.unistack.org/micro-config-flag/v3 go 1.18 -require go.unistack.org/micro/v3 v3.10.16 +require go.unistack.org/micro/v3 v3.10.36 -require github.com/imdario/mergo v0.3.13 // indirect +require ( + github.com/google/uuid v1.5.0 // indirect + github.com/imdario/mergo v0.3.16 // 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=