Explorar o código

allocate string for error description only if it really required

alextomaili %!s(int64=6) %!d(string=hai) anos
pai
achega
f71b9090aa
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      reflect_struct_decoder.go

+ 1 - 1
reflect_struct_decoder.go

@@ -530,8 +530,8 @@ func (decoder *generalStructDecoder) decodeOneField(ptr unsafe.Pointer, iter *It
 		}
 	}
 	if fieldDecoder == nil {
-		msg := "found unknown field: " + field
 		if decoder.disallowUnknownFields {
+			msg := "found unknown field: " + field
 			iter.ReportError("ReadObject", msg)
 		}
 		c := iter.nextToken()