diff --git a/pkg/build/norelease.go b/pkg/build/norelease.go new file mode 100644 index 000000000..f3ceb86ed --- /dev/null +++ b/pkg/build/norelease.go @@ -0,0 +1,7 @@ +//go:build !release + +package build + +func initReleaseOptions() { + CheckChildAlreadyExists = true +} diff --git a/pkg/build/options.go b/pkg/build/options.go new file mode 100644 index 000000000..101e32b2e --- /dev/null +++ b/pkg/build/options.go @@ -0,0 +1,9 @@ +package build + +var ( + CheckChildAlreadyExists = true +) + +func init() { + initReleaseOptions() +} diff --git a/pkg/build/release.go b/pkg/build/release.go new file mode 100644 index 000000000..aea0c4cf9 --- /dev/null +++ b/pkg/build/release.go @@ -0,0 +1,7 @@ +//go:build release + +package build + +func initReleaseOptions() { + CheckChildAlreadyExists = false +} diff --git a/pkg/decode/decode.go b/pkg/decode/decode.go index e899eac30..fcd985c19 100644 --- a/pkg/decode/decode.go +++ b/pkg/decode/decode.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "github.com/wader/fq/pkg/build" "io" "math/big" "regexp" @@ -720,7 +721,7 @@ func (d *D) AddChild(v *Value) { switch fv := d.Value.V.(type) { case *Compound: - if !fv.IsArray { + if build.CheckChildAlreadyExists && !fv.IsArray { for _, ff := range fv.Children { if ff.Name == v.Name { d.Fatalf("%q already exist in struct %s", v.Name, d.Value.Name)