remove redundant bool arg
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user