From f27c653a503dbde45790088b71b722072fedaf57 Mon Sep 17 00:00:00 2001 From: Kirill Korotaev Date: Sun, 12 Apr 2020 21:22:21 +0300 Subject: [PATCH] don't allow intern/nocopy tags at the same time --- gen/decoder.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gen/decoder.go b/gen/decoder.go index 4fddbff..aaee03f 100644 --- a/gen/decoder.go +++ b/gen/decoder.go @@ -3,6 +3,7 @@ package gen import ( "encoding" "encoding/json" + "errors" "fmt" "reflect" "strings" @@ -338,6 +339,9 @@ func (g *Generator) genStructFieldDecoder(t reflect.Type, f reflect.StructField) if tags.omit { return nil } + if tags.intern && tags.noCopy { + return errors.New("Mutually exclusive tags are specified: 'intern' and 'nocopy'") + } fmt.Fprintf(g.out, " case %q:\n", jsonName) if err := g.genTypeDecoder(f.Type, "out."+f.Name, tags, 3); err != nil {