Merge pull request #53 from jzhua/master

Follow standard encoding/json unmarshalling logic for pointers
This commit is contained in:
Victor Starodub
2016-08-17 00:55:11 +04:00
committed by GitHub
+3 -1
View File
@@ -118,7 +118,9 @@ func (g *Generator) genTypeDecoderNoCheck(t reflect.Type, out string, tags field
fmt.Fprintln(g.out, ws+" in.Skip()")
fmt.Fprintln(g.out, ws+" "+out+" = nil")
fmt.Fprintln(g.out, ws+"} else {")
fmt.Fprintln(g.out, ws+" "+out+" = new("+g.getType(t.Elem())+")")
fmt.Fprintln(g.out, ws+" if ("+out+") == nil {")
fmt.Fprintln(g.out, ws+" "+out+" = new("+g.getType(t.Elem())+")")
fmt.Fprintln(g.out, ws+" }")
g.genTypeDecoder(t.Elem(), "*"+out, tags, indent+1)