From dc04fdc7d03d90be6945462da49956331fea91f2 Mon Sep 17 00:00:00 2001 From: adman Date: Mon, 20 Apr 2026 23:38:02 +0200 Subject: [PATCH] remove redundant bool arg --- mapstructure/format.go | 8 ++++---- mapstructure/mapstructure_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mapstructure/format.go b/mapstructure/format.go index 480d527..c5af16b 100644 --- a/mapstructure/format.go +++ b/mapstructure/format.go @@ -36,15 +36,15 @@ func NewFormat(name string, opts ...Option) *Format { type Option func(*Format) -func WithRequireAll(require bool) Option { +func WithRequireAll() Option { return func(f *Format) { - f.requireAll = require + f.requireAll = true } } -func WithErrorOnExtra(errorOnExtra bool) Option { +func WithErrorOnExtra() Option { return func(f *Format) { - f.errorOnExtra = errorOnExtra + f.errorOnExtra = true } } diff --git a/mapstructure/mapstructure_test.go b/mapstructure/mapstructure_test.go index f65b3a5..b5596fa 100644 --- a/mapstructure/mapstructure_test.go +++ b/mapstructure/mapstructure_test.go @@ -67,7 +67,7 @@ func TestRequireAll(t *testing.T) { B int32 `nbt:"B,omitempty"` C int32 `nbt:"C"` } - f := NewFormat("nbt", WithRequireAll(true)) + f := NewFormat("nbt", WithRequireAll()) data := map[string]any{"A": int32(1), "C": int32(3)} var got Simple if err := f.Decode(data, &got); err != nil { @@ -83,7 +83,7 @@ func TestRequireAllMissing(t *testing.T) { A int32 `nbt:"A"` B int32 `nbt:"B"` } - f := NewFormat("nbt", WithRequireAll(true)) + f := NewFormat("nbt", WithRequireAll()) data := map[string]any{"A": int32(1)} var got Simple if err := f.Decode(data, &got); err == nil { @@ -96,7 +96,7 @@ func TestRequireAllOmitEmptyWins(t *testing.T) { A int32 `nbt:"A"` B int32 `nbt:"B,omitempty"` } - f := NewFormat("nbt", WithRequireAll(true)) + f := NewFormat("nbt", WithRequireAll()) data := map[string]any{"A": int32(1)} var got Simple if err := f.Decode(data, &got); err != nil { @@ -117,7 +117,7 @@ func TestSkipTag(t *testing.T) { } func TestErrorOnExtra(t *testing.T) { - f := NewFormat("nbt", WithErrorOnExtra(true)) + f := NewFormat("nbt", WithErrorOnExtra()) data := map[string]any{"Name": "test", "Secret": "shh", "Unknown": "extra"} var got Example if err := f.Decode(data, &got); err == nil {