mirror of
https://github.com/json-iterator/go.git
synced 2025-01-20 18:48:32 +02:00
fix go vet
This commit is contained in:
parent
6d0e6f3733
commit
9ecb1fd36d
@ -44,7 +44,7 @@ func ExampleUnmarshal() {
|
||||
// [{Name:Platypus Order:Monotremata} {Name:Quoll Order:Dasyuromorphia}]
|
||||
}
|
||||
|
||||
func ExampleMarshalWithBestPerformance() {
|
||||
func ExampleConfigFastest_Marshal() {
|
||||
type ColorGroup struct {
|
||||
ID int
|
||||
Name string
|
||||
@ -66,7 +66,7 @@ func ExampleMarshalWithBestPerformance() {
|
||||
// {"ID":1,"Name":"Reds","Colors":["Crimson","Red","Ruby","Maroon"]}
|
||||
}
|
||||
|
||||
func ExampleUnmarshalWithBestPerformance() {
|
||||
func ExampleConfigFastest_Unmarshal() {
|
||||
var jsonBlob = []byte(`[
|
||||
{"Name": "Platypus", "Order": "Monotremata"},
|
||||
{"Name": "Quoll", "Order": "Dasyuromorphia"}
|
||||
@ -87,7 +87,7 @@ func ExampleUnmarshalWithBestPerformance() {
|
||||
// [{Name:Platypus Order:Monotremata} {Name:Quoll Order:Dasyuromorphia}]
|
||||
}
|
||||
|
||||
func ExampleOneLine() {
|
||||
func ExampleGet() {
|
||||
val := []byte(`{"ID":1,"Name":"Reds","Colors":["Crimson","Red","Ruby","Maroon"]}`)
|
||||
fmt.Printf(Get(val, "Colors", 0).ToString())
|
||||
// Output:
|
||||
|
@ -34,11 +34,11 @@ type arrayEncoder struct {
|
||||
|
||||
func (encoder *arrayEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||
stream.WriteArrayStart()
|
||||
elemPtr := uintptr(ptr)
|
||||
encoder.elemEncoder.Encode(unsafe.Pointer(elemPtr), stream)
|
||||
elemPtr := unsafe.Pointer(ptr)
|
||||
encoder.elemEncoder.Encode(elemPtr, stream)
|
||||
for i := 1; i < encoder.arrayType.Len(); i++ {
|
||||
stream.WriteMore()
|
||||
elemPtr += encoder.elemType.Size()
|
||||
elemPtr = unsafe.Pointer(uintptr(elemPtr) + encoder.elemType.Size())
|
||||
encoder.elemEncoder.Encode(unsafe.Pointer(elemPtr), stream)
|
||||
}
|
||||
stream.WriteArrayEnd()
|
||||
|
@ -136,7 +136,7 @@ func encodeMapKey(key reflect.Value, stream *Stream) {
|
||||
stream.writeByte('"')
|
||||
return
|
||||
}
|
||||
stream.Error = &json.UnsupportedTypeError{key.Type()}
|
||||
stream.Error = &json.UnsupportedTypeError{Type:key.Type()}
|
||||
}
|
||||
|
||||
func (encoder *mapEncoder) EncodeInterface(val interface{}, stream *Stream) {
|
||||
@ -216,7 +216,7 @@ func (w *reflectWithString) resolve() error {
|
||||
w.s = strconv.FormatUint(w.v.Uint(), 10)
|
||||
return nil
|
||||
}
|
||||
return &json.UnsupportedTypeError{w.v.Type()}
|
||||
return &json.UnsupportedTypeError{Type:w.v.Type()}
|
||||
}
|
||||
|
||||
func (sv stringValues) Len() int { return len(sv) }
|
||||
|
@ -1015,8 +1015,8 @@ type structFieldDecoder struct {
|
||||
}
|
||||
|
||||
func (decoder *structFieldDecoder) Decode(ptr unsafe.Pointer, iter *Iterator) {
|
||||
fieldPtr := uintptr(ptr) + decoder.field.Offset
|
||||
decoder.fieldDecoder.Decode(unsafe.Pointer(fieldPtr), iter)
|
||||
fieldPtr := unsafe.Pointer(uintptr(ptr) + decoder.field.Offset)
|
||||
decoder.fieldDecoder.Decode(fieldPtr, iter)
|
||||
if iter.Error != nil && iter.Error != io.EOF {
|
||||
iter.Error = fmt.Errorf("%s: %s", decoder.field.Name, iter.Error.Error())
|
||||
}
|
||||
@ -1029,8 +1029,8 @@ type structFieldEncoder struct {
|
||||
}
|
||||
|
||||
func (encoder *structFieldEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||
fieldPtr := uintptr(ptr) + encoder.field.Offset
|
||||
encoder.fieldEncoder.Encode(unsafe.Pointer(fieldPtr), stream)
|
||||
fieldPtr := unsafe.Pointer(uintptr(ptr) + encoder.field.Offset)
|
||||
encoder.fieldEncoder.Encode(fieldPtr, stream)
|
||||
if stream.Error != nil && stream.Error != io.EOF {
|
||||
stream.Error = fmt.Errorf("%s: %s", encoder.field.Name, stream.Error.Error())
|
||||
}
|
||||
@ -1041,8 +1041,8 @@ func (encoder *structFieldEncoder) EncodeInterface(val interface{}, stream *Stre
|
||||
}
|
||||
|
||||
func (encoder *structFieldEncoder) IsEmpty(ptr unsafe.Pointer) bool {
|
||||
fieldPtr := uintptr(ptr) + encoder.field.Offset
|
||||
return encoder.fieldEncoder.IsEmpty(unsafe.Pointer(fieldPtr))
|
||||
fieldPtr := unsafe.Pointer(uintptr(ptr) + encoder.field.Offset)
|
||||
return encoder.fieldEncoder.IsEmpty(fieldPtr)
|
||||
}
|
||||
|
||||
type structEncoder struct {
|
||||
|
@ -43,11 +43,11 @@ func (encoder *sliceEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
|
||||
return
|
||||
}
|
||||
stream.WriteArrayStart()
|
||||
elemPtr := uintptr(slice.Data)
|
||||
elemPtr := unsafe.Pointer(slice.Data)
|
||||
encoder.elemEncoder.Encode(unsafe.Pointer(elemPtr), stream)
|
||||
for i := 1; i < slice.Len; i++ {
|
||||
stream.WriteMore()
|
||||
elemPtr += encoder.elemType.Size()
|
||||
elemPtr = unsafe.Pointer(uintptr(elemPtr) + encoder.elemType.Size())
|
||||
encoder.elemEncoder.Encode(unsafe.Pointer(elemPtr), stream)
|
||||
}
|
||||
stream.WriteArrayEnd()
|
||||
|
@ -1,3 +1,4 @@
|
||||
package test
|
||||
|
||||
// Only used in test
|
||||
type T int8
|
||||
|
Loading…
x
Reference in New Issue
Block a user