Tao Wen 7 anos atrás
pai
commit
fff342fd04
72 arquivos alterados com 163 adições e 174 exclusões
  1. 2 2
      any.go
  2. 1 1
      any_tests/jsoniter_any_array_test.go
  3. 1 1
      any_tests/jsoniter_any_bool_test.go
  4. 1 1
      any_tests/jsoniter_any_float_test.go
  5. 1 1
      any_tests/jsoniter_any_int_test.go
  6. 1 1
      any_tests/jsoniter_any_map_test.go
  7. 1 1
      any_tests/jsoniter_any_null_test.go
  8. 2 2
      any_tests/jsoniter_any_object_test.go
  9. 1 1
      any_tests/jsoniter_any_string_test.go
  10. 1 1
      any_tests/jsoniter_must_be_valid_test.go
  11. 1 1
      any_tests/jsoniter_wrap_test.go
  12. 4 5
      api_tests/config_test.go
  13. 3 4
      api_tests/decoder_test.go
  14. 1 1
      api_tests/encoder_18_test.go
  15. 4 4
      api_tests/encoder_test.go
  16. 1 1
      api_tests/marshal_indent_test.go
  17. 1 1
      benchmarks/jsoniter_large_file_test.go
  18. 2 2
      config.go
  19. 0 2
      example_test.go
  20. 4 5
      extension_tests/decoder_test.go
  21. 4 4
      extension_tests/extension_test.go
  22. 1 1
      misc_tests/jsoniter_array_test.go
  23. 2 2
      misc_tests/jsoniter_bool_test.go
  24. 1 1
      misc_tests/jsoniter_float_test.go
  25. 1 1
      misc_tests/jsoniter_int_test.go
  26. 2 2
      misc_tests/jsoniter_interface_test.go
  27. 1 1
      misc_tests/jsoniter_iterator_test.go
  28. 1 1
      misc_tests/jsoniter_map_test.go
  29. 1 1
      misc_tests/jsoniter_nested_test.go
  30. 1 1
      misc_tests/jsoniter_null_test.go
  31. 3 3
      misc_tests/jsoniter_object_test.go
  32. 10 10
      misc_tests/jsoniter_raw_message_test.go
  33. 1 1
      reflect.go
  34. 1 1
      reflect_array.go
  35. 1 1
      reflect_dynamic.go
  36. 5 5
      reflect_extension.go
  37. 2 2
      reflect_json_number.go
  38. 2 2
      reflect_json_raw_message.go
  39. 2 2
      reflect_map.go
  40. 2 2
      reflect_marshaler.go
  41. 4 4
      reflect_native.go
  42. 1 1
      reflect_optional.go
  43. 1 1
      reflect_slice.go
  44. 2 2
      reflect_struct_decoder.go
  45. 1 1
      reflect_struct_encoder.go
  46. 1 1
      skip_tests/jsoniter_skip_test.go
  47. 1 1
      skip_tests/skip_test.go
  48. 1 1
      skip_tests/string_test.go
  49. 1 1
      skip_tests/struct_test.go
  50. 4 4
      stream_int.go
  51. 1 1
      type_tests/array_test.go
  52. 2 3
      type_tests/map_key_test.go
  53. 2 2
      type_tests/marshaler_string_test.go
  54. 2 2
      type_tests/marshaler_struct_test.go
  55. 1 3
      type_tests/slice_test.go
  56. 1 1
      type_tests/struct_embedded_test.go
  57. 6 6
      type_tests/struct_tags_test.go
  58. 2 2
      type_tests/text_marshaler_string_test.go
  59. 2 2
      type_tests/text_marshaler_struct_test.go
  60. 6 6
      type_tests/type_test.go
  61. 3 3
      value_tests/array_test.go
  62. 6 6
      value_tests/eface_test.go
  63. 5 6
      value_tests/float_test.go
  64. 1 1
      value_tests/iface_test.go
  65. 4 5
      value_tests/int_test.go
  66. 2 2
      value_tests/invalid_test.go
  67. 5 5
      value_tests/map_test.go
  68. 5 6
      value_tests/marshaler_test.go
  69. 1 1
      value_tests/raw_message_test.go
  70. 2 2
      value_tests/string_test.go
  71. 2 2
      value_tests/struct_test.go
  72. 8 8
      value_tests/value_test.go

+ 2 - 2
any.go

@@ -3,11 +3,11 @@ package jsoniter
 import (
 	"errors"
 	"fmt"
+	"github.com/v2pro/plz/reflect2"
 	"io"
 	"reflect"
-	"unsafe"
-	"github.com/v2pro/plz/reflect2"
 	"strconv"
+	"unsafe"
 )
 
 // Any generic object representation.

+ 1 - 1
any_tests/jsoniter_any_array_test.go

@@ -3,8 +3,8 @@ package any_tests
 import (
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_read_empty_array_as_any(t *testing.T) {

+ 1 - 1
any_tests/jsoniter_any_bool_test.go

@@ -4,8 +4,8 @@ import (
 	"fmt"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 var boolConvertMap = map[string]bool{

+ 1 - 1
any_tests/jsoniter_any_float_test.go

@@ -3,8 +3,8 @@ package any_tests
 import (
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 var floatConvertMap = map[string]float64{

+ 1 - 1
any_tests/jsoniter_any_int_test.go

@@ -4,8 +4,8 @@ import (
 	"fmt"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 var intConvertMap = map[string]int{

+ 1 - 1
any_tests/jsoniter_any_map_test.go

@@ -1,9 +1,9 @@
 package any_tests
 
 import (
+	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"testing"
-	"github.com/json-iterator/go"
 )
 
 func Test_wrap_map(t *testing.T) {

+ 1 - 1
any_tests/jsoniter_any_null_test.go

@@ -1,9 +1,9 @@
 package any_tests
 
 import (
+	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"testing"
-	"github.com/json-iterator/go"
 )
 
 func Test_read_null_as_any(t *testing.T) {

+ 2 - 2
any_tests/jsoniter_any_object_test.go

@@ -3,8 +3,8 @@ package any_tests
 import (
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_read_object_as_any(t *testing.T) {
@@ -120,4 +120,4 @@ func Test_object_wrapper_any_get_all(t *testing.T) {
 	should.NotContains(any.Keys(), "Field3")
 
 	//should.Contains(any.GetObject()["Field1"].GetArray()[0], 1)
-}
+}

+ 1 - 1
any_tests/jsoniter_any_string_test.go

@@ -3,8 +3,8 @@ package any_tests
 import (
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 var stringConvertMap = map[string]string{

+ 1 - 1
any_tests/jsoniter_must_be_valid_test.go

@@ -3,8 +3,8 @@ package any_tests
 import (
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 // if must be valid is useless, just drop this test

+ 1 - 1
any_tests/jsoniter_wrap_test.go

@@ -3,8 +3,8 @@ package any_tests
 import (
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_wrap_and_valuetype_everything(t *testing.T) {

+ 4 - 5
api_tests/config_test.go

@@ -1,10 +1,10 @@
 package test
 
 import (
-	"testing"
-	"github.com/stretchr/testify/require"
-	"github.com/json-iterator/go"
 	"encoding/json"
+	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
+	"testing"
 )
 
 func Test_use_number_for_unmarshal(t *testing.T) {
@@ -23,7 +23,6 @@ func Test_customize_float_marshal(t *testing.T) {
 	should.Equal("1.234568", str)
 }
 
-
 func Test_customize_tag_key(t *testing.T) {
 
 	type TestObject struct {
@@ -45,4 +44,4 @@ func Test_read_large_number_as_interface(t *testing.T) {
 	output, err := jsoniter.MarshalToString(val)
 	should.Nil(err)
 	should.Equal(`123456789123456789123456789`, output)
-}
+}

+ 3 - 4
api_tests/decoder_test.go

@@ -2,11 +2,11 @@ package test
 
 import (
 	"bytes"
-	"github.com/stretchr/testify/require"
-	"testing"
+	"encoding/json"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 	"io/ioutil"
-	"encoding/json"
+	"testing"
 )
 
 func Test_disallowUnknownFields(t *testing.T) {
@@ -18,7 +18,6 @@ func Test_disallowUnknownFields(t *testing.T) {
 	should.Error(decoder.Decode(&obj))
 }
 
-
 func Test_new_decoder(t *testing.T) {
 	should := require.New(t)
 	decoder1 := json.NewDecoder(bytes.NewBufferString(`[1][2]`))

+ 1 - 1
api_tests/encoder_18_test.go

@@ -8,8 +8,8 @@ import (
 	"testing"
 	"unicode/utf8"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_new_encoder(t *testing.T) {

+ 4 - 4
api_tests/encoder_test.go

@@ -1,11 +1,11 @@
 package test
 
 import (
-	"testing"
-	"github.com/stretchr/testify/require"
 	"bytes"
-	"github.com/json-iterator/go"
 	"encoding/json"
+	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
+	"testing"
 )
 
 // Standard Encoder has trailing newline.
@@ -17,4 +17,4 @@ func TestEncoderHasTrailingNewline(t *testing.T) {
 	stdenc := json.NewEncoder(&stdbuf)
 	stdenc.Encode(1)
 	should.Equal(stdbuf.Bytes(), buf.Bytes())
-}
+}

+ 1 - 1
api_tests/marshal_indent_test.go

@@ -2,9 +2,9 @@ package test
 
 import (
 	"encoding/json"
+	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"testing"
-	"github.com/json-iterator/go"
 )
 
 func Test_marshal_indent(t *testing.T) {

+ 1 - 1
benchmarks/jsoniter_large_file_test.go

@@ -2,10 +2,10 @@ package test
 
 import (
 	"encoding/json"
+	"github.com/json-iterator/go"
 	"io/ioutil"
 	"os"
 	"testing"
-	"github.com/json-iterator/go"
 )
 
 //func Test_large_file(t *testing.T) {

+ 2 - 2
config.go

@@ -2,10 +2,10 @@ package jsoniter
 
 import (
 	"encoding/json"
-	"io"
-	"unsafe"
 	"github.com/v2pro/plz/reflect2"
+	"io"
 	"sync"
+	"unsafe"
 )
 
 // Config customize how the API should behave.

+ 0 - 2
example_test.go

@@ -111,7 +111,6 @@ func ExampleMapKey() {
 
 type MyKey string
 
-
 func (m *MyKey) MarshalText() ([]byte, error) {
 	return []byte(strings.Replace(string(*m), "h", "H", -1)), nil
 }
@@ -120,4 +119,3 @@ func (m *MyKey) UnmarshalText(text []byte) error {
 	*m = MyKey(text[:3])
 	return nil
 }
-

+ 4 - 5
extension_tests/decoder_test.go

@@ -1,12 +1,12 @@
 package test
 
 import (
-	"testing"
-	"unsafe"
-	"time"
 	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"strconv"
+	"testing"
+	"time"
+	"unsafe"
 )
 
 func Test_customize_type_decoder(t *testing.T) {
@@ -61,7 +61,6 @@ func Test_customize_field_decoder(t *testing.T) {
 	}
 }
 
-
 func Test_recursive_empty_interface_customization(t *testing.T) {
 	t.Skip()
 	var obj interface{}
@@ -98,4 +97,4 @@ func Test_read_custom_interface(t *testing.T) {
 	err := jsoniter.UnmarshalFromString(`"hello"`, &val)
 	should.Nil(err)
 	should.Equal("hello", val.Hello())
-}
+}

+ 4 - 4
extension_tests/extension_test.go

@@ -1,13 +1,13 @@
 package test
 
 import (
-	"unsafe"
-	"strconv"
-	"testing"
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 	"github.com/v2pro/plz/reflect2"
 	"reflect"
+	"strconv"
+	"testing"
+	"unsafe"
 )
 
 type TestObject1 struct {

+ 1 - 1
misc_tests/jsoniter_array_test.go

@@ -3,9 +3,9 @@ package misc_tests
 import (
 	"bytes"
 	"encoding/json"
+	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"testing"
-	"github.com/json-iterator/go"
 )
 
 func Test_empty_array(t *testing.T) {

+ 2 - 2
misc_tests/jsoniter_bool_test.go

@@ -4,8 +4,8 @@ import (
 	"bytes"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_true(t *testing.T) {
@@ -44,4 +44,4 @@ func Test_write_val_bool(t *testing.T) {
 	should.Equal(stream.Buffered(), 0)
 	should.Nil(stream.Error)
 	should.Equal("true", buf.String())
-}
+}

+ 1 - 1
misc_tests/jsoniter_float_test.go

@@ -4,8 +4,8 @@ import (
 	"encoding/json"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_read_big_float(t *testing.T) {

+ 1 - 1
misc_tests/jsoniter_int_test.go

@@ -9,8 +9,8 @@ import (
 	"strconv"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_read_uint64_invalid(t *testing.T) {

+ 2 - 2
misc_tests/jsoniter_interface_test.go

@@ -2,10 +2,10 @@ package misc_tests
 
 import (
 	"encoding/json"
-	"testing"
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 	"io"
+	"testing"
 )
 
 func Test_nil_non_empty_interface(t *testing.T) {

+ 1 - 1
misc_tests/jsoniter_iterator_test.go

@@ -7,8 +7,8 @@ import (
 	"strconv"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_bad_case(t *testing.T) {

+ 1 - 1
misc_tests/jsoniter_map_test.go

@@ -5,9 +5,9 @@ import (
 	"math/big"
 	"testing"
 
+	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"strings"
-	"github.com/json-iterator/go"
 )
 
 func Test_decode_TextMarshaler_key_map(t *testing.T) {

+ 1 - 1
misc_tests/jsoniter_nested_test.go

@@ -2,9 +2,9 @@ package misc_tests
 
 import (
 	"encoding/json"
+	"github.com/json-iterator/go"
 	"reflect"
 	"testing"
-	"github.com/json-iterator/go"
 )
 
 type Level1 struct {

+ 1 - 1
misc_tests/jsoniter_null_test.go

@@ -5,8 +5,8 @@ import (
 	"io"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_read_null(t *testing.T) {

+ 3 - 3
misc_tests/jsoniter_object_test.go

@@ -4,10 +4,10 @@ import (
 	"bytes"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
-	"time"
+	"github.com/stretchr/testify/require"
 	"strings"
+	"time"
 )
 
 func Test_empty_object(t *testing.T) {
@@ -129,4 +129,4 @@ func Test_reader_and_load_more(t *testing.T) {
 	decoder := jsoniter.ConfigCompatibleWithStandardLibrary.NewDecoder(reader)
 	obj := TestObject{}
 	should.Nil(decoder.Decode(&obj))
-}
+}

+ 10 - 10
misc_tests/jsoniter_raw_message_test.go

@@ -2,10 +2,10 @@ package misc_tests
 
 import (
 	"encoding/json"
+	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"strings"
 	"testing"
-	"github.com/json-iterator/go"
 )
 
 func Test_jsoniter_RawMessage(t *testing.T) {
@@ -45,18 +45,18 @@ func Test_marshal_invalid_json_raw_message(t *testing.T) {
 func Test_raw_message_memory_not_copied_issue(t *testing.T) {
 	jsonStream := `{"name":"xxxxx","bundle_id":"com.zonst.majiang","app_platform":"ios","app_category":"100103", "budget_day":1000,"bidding_min":1,"bidding_max":2,"bidding_type":"CPM", "freq":{"open":true,"type":"day","num":100},"speed":1, "targeting":{"vendor":{"open":true,"list":["zonst"]}, "geo_code":{"open":true,"list":["156110100"]},"app_category":{"open":true,"list":["100101"]}, "day_parting":{"open":true,"list":["100409","100410"]},"device_type":{"open":true,"list":["ipad"]}, "os_version":{"open":true,"list":[10]},"carrier":{"open":true,"list":["mobile"]}, "network":{"open":true,"list":["4G"]}},"url":{"tracking_imp_url":"http://www.baidu.com", "tracking_clk_url":"http://www.baidu.com","jump_url":"http://www.baidu.com","deep_link_url":"http://www.baidu.com"}}`
 	type IteratorObject struct {
-		Name        *string     `json:"name"`
-		BundleId    *string     `json:"bundle_id"`
-		AppCategory *string     `json:"app_category"`
-		AppPlatform *string     `json:"app_platform"`
-		BudgetDay   *float32    `json:"budget_day"`
-		BiddingMax  *float32    `json:"bidding_max"`
-		BiddingMin  *float32    `json:"bidding_min"`
-		BiddingType *string     `json:"bidding_type"`
+		Name        *string              `json:"name"`
+		BundleId    *string              `json:"bundle_id"`
+		AppCategory *string              `json:"app_category"`
+		AppPlatform *string              `json:"app_platform"`
+		BudgetDay   *float32             `json:"budget_day"`
+		BiddingMax  *float32             `json:"bidding_max"`
+		BiddingMin  *float32             `json:"bidding_min"`
+		BiddingType *string              `json:"bidding_type"`
 		Freq        *jsoniter.RawMessage `json:"freq"`
 		Targeting   *jsoniter.RawMessage `json:"targeting"`
 		Url         *jsoniter.RawMessage `json:"url"`
-		Speed       *int        `json:"speed" db:"speed"`
+		Speed       *int                 `json:"speed" db:"speed"`
 	}
 
 	obj := &IteratorObject{}

+ 1 - 1
reflect.go

@@ -2,9 +2,9 @@ package jsoniter
 
 import (
 	"fmt"
+	"github.com/v2pro/plz/reflect2"
 	"reflect"
 	"unsafe"
-	"github.com/v2pro/plz/reflect2"
 )
 
 // ValDecoder is an internal type registered to cache as needed.

+ 1 - 1
reflect_array.go

@@ -2,9 +2,9 @@ package jsoniter
 
 import (
 	"fmt"
+	"github.com/v2pro/plz/reflect2"
 	"io"
 	"unsafe"
-	"github.com/v2pro/plz/reflect2"
 )
 
 func decoderOfArray(ctx *ctx, typ reflect2.Type) ValDecoder {

+ 1 - 1
reflect_dynamic.go

@@ -2,8 +2,8 @@ package jsoniter
 
 import (
 	"github.com/v2pro/plz/reflect2"
-	"unsafe"
 	"reflect"
+	"unsafe"
 )
 
 type dynamicEncoder struct {

+ 5 - 5
reflect_extension.go

@@ -2,12 +2,12 @@ package jsoniter
 
 import (
 	"fmt"
+	"github.com/v2pro/plz/reflect2"
 	"reflect"
 	"sort"
 	"strings"
 	"unicode"
 	"unsafe"
-	"github.com/v2pro/plz/reflect2"
 )
 
 var typeDecoders = map[string]ValDecoder{}
@@ -18,8 +18,8 @@ var extensions = []Extension{}
 
 // StructDescriptor describe how should we encode/decode the struct
 type StructDescriptor struct {
-	Type               reflect2.Type
-	Fields             []*Binding
+	Type   reflect2.Type
+	Fields []*Binding
 }
 
 // GetField get one field from the descriptor by its name.
@@ -387,8 +387,8 @@ func describeStruct(ctx *ctx, typ reflect2.Type) *StructDescriptor {
 }
 func createStructDescriptor(ctx *ctx, typ reflect2.Type, bindings []*Binding, embeddedBindings []*Binding) *StructDescriptor {
 	structDescriptor := &StructDescriptor{
-		Type:               typ,
-		Fields:             bindings,
+		Type:   typ,
+		Fields: bindings,
 	}
 	for _, extension := range extensions {
 		extension.UpdateStructDescriptor(structDescriptor)

+ 2 - 2
reflect_json_number.go

@@ -2,9 +2,9 @@ package jsoniter
 
 import (
 	"encoding/json"
+	"github.com/v2pro/plz/reflect2"
 	"strconv"
 	"unsafe"
-	"github.com/v2pro/plz/reflect2"
 )
 
 type Number string
@@ -109,4 +109,4 @@ func (codec *jsoniterNumberCodec) Encode(ptr unsafe.Pointer, stream *Stream) {
 
 func (codec *jsoniterNumberCodec) IsEmpty(ptr unsafe.Pointer) bool {
 	return len(*((*Number)(ptr))) == 0
-}
+}

+ 2 - 2
reflect_json_raw_message.go

@@ -1,9 +1,9 @@
 package jsoniter
 
 import (
-	"unsafe"
 	"encoding/json"
 	"github.com/v2pro/plz/reflect2"
+	"unsafe"
 )
 
 var jsonRawMessageType = reflect2.TypeOfPtr((*json.RawMessage)(nil)).Elem()
@@ -57,4 +57,4 @@ func (codec *jsoniterRawMessageCodec) Encode(ptr unsafe.Pointer, stream *Stream)
 
 func (codec *jsoniterRawMessageCodec) IsEmpty(ptr unsafe.Pointer) bool {
 	return len(*((*RawMessage)(ptr))) == 0
-}
+}

+ 2 - 2
reflect_map.go

@@ -1,11 +1,11 @@
 package jsoniter
 
 import (
+	"fmt"
+	"github.com/v2pro/plz/reflect2"
 	"reflect"
 	"sort"
 	"unsafe"
-	"github.com/v2pro/plz/reflect2"
-	"fmt"
 )
 
 func decoderOfMap(ctx *ctx, typ reflect2.Type) ValDecoder {

+ 2 - 2
reflect_marshaler.go

@@ -1,10 +1,10 @@
 package jsoniter
 
 import (
-	"github.com/v2pro/plz/reflect2"
-	"unsafe"
 	"encoding"
 	"encoding/json"
+	"github.com/v2pro/plz/reflect2"
+	"unsafe"
 )
 
 var marshalerType = reflect2.TypeOfPtr((*json.Marshaler)(nil)).Elem()

+ 4 - 4
reflect_native.go

@@ -2,10 +2,10 @@ package jsoniter
 
 import (
 	"encoding/base64"
-	"reflect"
-	"unsafe"
 	"github.com/v2pro/plz/reflect2"
+	"reflect"
 	"strconv"
+	"unsafe"
 )
 
 const ptrSize = 32 << uintptr(^uintptr(0)>>63)
@@ -405,7 +405,7 @@ func (codec *boolCodec) IsEmpty(ptr unsafe.Pointer) bool {
 }
 
 type base64Codec struct {
-	sliceType *reflect2.UnsafeSliceType
+	sliceType    *reflect2.UnsafeSliceType
 	sliceDecoder ValDecoder
 }
 
@@ -418,7 +418,7 @@ func (codec *base64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
 	case StringValue:
 		encoding := base64.StdEncoding
 		src := iter.SkipAndReturnBytes()
-		src = src[1: len(src)-1]
+		src = src[1 : len(src)-1]
 		decodedLen := encoding.DecodedLen(len(src))
 		dst := make([]byte, decodedLen)
 		len, err := encoding.Decode(dst, src)

+ 1 - 1
reflect_optional.go

@@ -1,9 +1,9 @@
 package jsoniter
 
 import (
+	"github.com/v2pro/plz/reflect2"
 	"reflect"
 	"unsafe"
-	"github.com/v2pro/plz/reflect2"
 )
 
 func decoderOfOptional(ctx *ctx, typ reflect2.Type) ValDecoder {

+ 1 - 1
reflect_slice.go

@@ -2,9 +2,9 @@ package jsoniter
 
 import (
 	"fmt"
+	"github.com/v2pro/plz/reflect2"
 	"io"
 	"unsafe"
-	"github.com/v2pro/plz/reflect2"
 )
 
 func decoderOfSlice(ctx *ctx, typ reflect2.Type) ValDecoder {

+ 2 - 2
reflect_struct_decoder.go

@@ -2,10 +2,10 @@ package jsoniter
 
 import (
 	"fmt"
+	"github.com/v2pro/plz/reflect2"
 	"io"
 	"strings"
 	"unsafe"
-	"github.com/v2pro/plz/reflect2"
 )
 
 func decoderOfStruct(ctx *ctx, typ reflect2.Type) ValDecoder {
@@ -1031,4 +1031,4 @@ func (decoder *stringModeNumberDecoder) Decode(ptr unsafe.Pointer, iter *Iterato
 		iter.ReportError("stringModeNumberDecoder", `expect ", but found `+string([]byte{c}))
 		return
 	}
-}
+}

+ 1 - 1
reflect_struct_encoder.go

@@ -2,10 +2,10 @@ package jsoniter
 
 import (
 	"fmt"
+	"github.com/v2pro/plz/reflect2"
 	"io"
 	"reflect"
 	"unsafe"
-	"github.com/v2pro/plz/reflect2"
 )
 
 func encoderOfStruct(ctx *ctx, typ reflect2.Type) ValEncoder {

+ 1 - 1
skip_tests/jsoniter_skip_test.go

@@ -5,8 +5,8 @@ import (
 	"encoding/json"
 	"testing"
 
-	"github.com/stretchr/testify/require"
 	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 )
 
 func Test_skip_number_in_array(t *testing.T) {

+ 1 - 1
skip_tests/skip_test.go

@@ -6,8 +6,8 @@ import (
 	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"io"
-	"testing"
 	"reflect"
+	"testing"
 )
 
 type testCase struct {

+ 1 - 1
skip_tests/string_test.go

@@ -14,4 +14,4 @@ func init() {
 			`"\t"`,     // valid
 		},
 	})
-}
+}

+ 1 - 1
skip_tests/struct_test.go

@@ -16,4 +16,4 @@ func init() {
 			`{abc}`, // invalid
 		},
 	})
-}
+}

+ 4 - 4
stream_int.go

@@ -17,16 +17,16 @@ func init() {
 func writeFirstBuf(space []byte, v uint32) []byte {
 	start := v >> 24
 	if start == 0 {
-		space = append(space, byte(v >> 16), byte(v >> 8))
+		space = append(space, byte(v>>16), byte(v>>8))
 	} else if start == 1 {
-		space = append(space, byte(v >> 8))
+		space = append(space, byte(v>>8))
 	}
 	space = append(space, byte(v))
 	return space
 }
 
 func writeBuf(buf []byte, v uint32) []byte {
-	return append(buf, byte(v >> 16), byte(v >> 8), byte(v))
+	return append(buf, byte(v>>16), byte(v>>8), byte(v))
 }
 
 // WriteUint8 write uint8 to stream
@@ -91,7 +91,7 @@ func (stream *Stream) WriteUint32(val uint32) {
 		stream.buf = writeFirstBuf(stream.buf, digits[q2])
 	} else {
 		r3 := q2 - q3*1000
-		stream.buf = append(stream.buf, byte(q3 + '0'))
+		stream.buf = append(stream.buf, byte(q3+'0'))
 		stream.buf = writeBuf(stream.buf, digits[r3])
 	}
 	stream.buf = writeBuf(stream.buf, digits[r2])

+ 1 - 1
type_tests/array_test.go

@@ -60,4 +60,4 @@ func init() {
 }
 
 type structEmpty struct{}
-type arrayAlis [4]stringAlias
+type arrayAlis [4]stringAlias

+ 2 - 3
type_tests/map_key_test.go

@@ -1,8 +1,8 @@
 package test
 
 import (
-	"strings"
 	"encoding"
+	"strings"
 )
 
 func init() {
@@ -26,7 +26,6 @@ func (k *stringKeyType) UnmarshalText(text []byte) error {
 var _ encoding.TextMarshaler = stringKeyType("")
 var _ encoding.TextUnmarshaler = new(stringKeyType)
 
-
 type structKeyType struct {
 	X string
 }
@@ -41,4 +40,4 @@ func (k *structKeyType) UnmarshalText(text []byte) error {
 }
 
 var _ encoding.TextMarshaler = structKeyType{}
-var _ encoding.TextUnmarshaler = &structKeyType{}
+var _ encoding.TextUnmarshaler = &structKeyType{}

+ 2 - 2
type_tests/marshaler_string_test.go

@@ -3,8 +3,8 @@ package test
 import (
 	"bytes"
 	"encoding/base64"
-	"strings"
 	"encoding/json"
+	"strings"
 )
 
 type StringMarshaler string
@@ -49,4 +49,4 @@ var _ json.Unmarshaler = new(StringMarshaler)
 
 func init() {
 	testCases = append(testCases, (*StringMarshaler)(nil))
-}
+}

+ 2 - 2
type_tests/marshaler_struct_test.go

@@ -1,10 +1,10 @@
 package test
 
 import (
-	"strings"
-	"encoding/base64"
 	"bytes"
+	"encoding/base64"
 	"encoding/json"
+	"strings"
 )
 
 type structMarshaler struct {

+ 1 - 3
type_tests/slice_test.go

@@ -91,7 +91,6 @@ func (p *jsonMarshaler) UnmarshalJSON(input []byte) error {
 	return nil
 }
 
-
 type jsonMarshalerMap map[int]int
 
 func (p *jsonMarshalerMap) MarshalJSON() ([]byte, error) {
@@ -117,11 +116,10 @@ func (p *textMarshaler) UnmarshalText(input []byte) error {
 
 type textMarshalerMap map[int]int
 
-
 func (p *textMarshalerMap) MarshalText() ([]byte, error) {
 	return []byte(`{}`), nil
 }
 
 func (p *textMarshalerMap) UnmarshalText(input []byte) error {
 	return nil
-}
+}

+ 1 - 1
type_tests/struct_embedded_test.go

@@ -230,4 +230,4 @@ type EmbeddedPtrOption struct {
 
 type EmbeddedPtr struct {
 	EmbeddedPtrOption `json:","`
-}
+}

+ 6 - 6
type_tests/struct_tags_test.go

@@ -192,12 +192,12 @@ type StringFieldNameE struct {
 }
 
 type StringFieldName struct {
-	F1 string        `json:"F1"`
-	F2 string        `json:"f2"`
-	F3 string        `json:"-"`
-	F4 string        `json:"-,"`
-	F5 string        `json:","`
-	F6 string        `json:""`
+	F1               string `json:"F1"`
+	F2               string `json:"f2"`
+	F3               string `json:"-"`
+	F4               string `json:"-,"`
+	F5               string `json:","`
+	F6               string `json:""`
 	StringFieldNameE `json:"e"`
 }
 

+ 2 - 2
type_tests/text_marshaler_string_test.go

@@ -1,10 +1,10 @@
 package test
 
 import (
-	"strings"
-	"encoding"
 	"bytes"
+	"encoding"
 	"encoding/base64"
+	"strings"
 )
 
 func init() {

+ 2 - 2
type_tests/text_marshaler_struct_test.go

@@ -2,9 +2,9 @@ package test
 
 import (
 	"bytes"
+	"encoding"
 	"encoding/base64"
 	"strings"
-	"encoding"
 )
 
 func init() {
@@ -66,4 +66,4 @@ func (m *structTextMarshaler) UnmarshalText(text []byte) error {
 var _ encoding.TextMarshaler = structTextMarshaler{}
 var _ encoding.TextUnmarshaler = &structTextMarshaler{}
 
-type structTextMarshalerAlias structTextMarshaler
+type structTextMarshalerAlias structTextMarshaler

+ 6 - 6
type_tests/type_test.go

@@ -1,15 +1,15 @@
 package test
 
 import (
-	"testing"
-	"reflect"
+	"bytes"
+	"encoding/json"
 	"fmt"
+	"github.com/davecgh/go-spew/spew"
 	"github.com/google/gofuzz"
-	"strings"
 	"github.com/json-iterator/go"
-	"encoding/json"
-	"bytes"
-	"github.com/davecgh/go-spew/spew"
+	"reflect"
+	"strings"
+	"testing"
 )
 
 var testCases []interface{}

+ 3 - 3
value_tests/array_test.go

@@ -8,13 +8,13 @@ func init() {
 		[2]*float64{},
 	)
 	unmarshalCases = append(unmarshalCases, unmarshalCase{
-		ptr: (*[0]int)(nil),
+		ptr:   (*[0]int)(nil),
 		input: `[1]`,
 	}, unmarshalCase{
-		ptr: (*[1]int)(nil),
+		ptr:   (*[1]int)(nil),
 		input: `[2]`,
 	}, unmarshalCase{
-		ptr: (*[1]int)(nil),
+		ptr:   (*[1]int)(nil),
 		input: `[]`,
 	})
 }

+ 6 - 6
value_tests/eface_test.go

@@ -8,16 +8,16 @@ func init() {
 		return &val
 	}
 	unmarshalCases = append(unmarshalCases, unmarshalCase{
-		ptr: (**interface{})(nil),
+		ptr:   (**interface{})(nil),
 		input: `"hello"`,
 	}, unmarshalCase{
-		ptr: (**interface{})(nil),
+		ptr:   (**interface{})(nil),
 		input: `1e1`,
 	}, unmarshalCase{
-		ptr: (**interface{})(nil),
+		ptr:   (**interface{})(nil),
 		input: `1.0e1`,
 	}, unmarshalCase{
-		ptr: (*[]interface{})(nil),
+		ptr:   (*[]interface{})(nil),
 		input: `[1.0e1]`,
 	}, unmarshalCase{
 		ptr: (*struct {
@@ -66,12 +66,12 @@ func init() {
 		}{"hello"},
 		struct {
 			Field interface{}
-		}{struct{
+		}{struct {
 			field chan int
 		}{}},
 		struct {
 			Field interface{}
-		}{struct{
+		}{struct {
 			Field *int
 		}{pInt(100)}},
 	)

+ 5 - 6
value_tests/float_test.go

@@ -1,13 +1,13 @@
 package test
 
 import (
+	"bytes"
+	"encoding/json"
 	"fmt"
-	"testing"
+	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"strconv"
-	"bytes"
-	"github.com/json-iterator/go"
-	"encoding/json"
+	"testing"
 )
 
 func Test_read_float(t *testing.T) {
@@ -50,7 +50,6 @@ func Test_read_float(t *testing.T) {
 	}
 }
 
-
 func Test_write_float32(t *testing.T) {
 	vals := []float32{0, 1, -1, 99, 0xff, 0xfff, 0xffff, 0xfffff, 0xffffff, 0x4ffffff, 0xfffffff,
 		-0x4ffffff, -0xfffffff, 1.2345, 1.23456, 1.234567, 1.001}
@@ -127,4 +126,4 @@ func Test_write_float64(t *testing.T) {
 	stream = jsoniter.NewStream(jsoniter.ConfigDefault, nil, 0)
 	stream.WriteFloat64(float64(0.0000001))
 	should.Equal("1e-07", string(stream.Buffer()))
-}
+}

+ 1 - 1
value_tests/iface_test.go

@@ -17,7 +17,7 @@ func init() {
 		pCloser2("hello"),
 	)
 	unmarshalCases = append(unmarshalCases, unmarshalCase{
-		ptr: (*[]io.Closer)(nil),
+		ptr:   (*[]io.Closer)(nil),
 		input: "[null]",
 	}, unmarshalCase{
 		obj: func() interface{} {

+ 4 - 5
value_tests/int_test.go

@@ -1,12 +1,12 @@
 package test
 
 import (
+	"bytes"
+	"fmt"
+	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/require"
 	"strconv"
-	"fmt"
 	"testing"
-	"bytes"
-	"github.com/json-iterator/go"
 )
 
 func init() {
@@ -158,7 +158,6 @@ func Test_read_int64(t *testing.T) {
 	}
 }
 
-
 func Test_write_uint8(t *testing.T) {
 	vals := []uint8{0, 1, 11, 111, 255}
 	for _, val := range vals {
@@ -417,4 +416,4 @@ func Test_write_int64(t *testing.T) {
 	stream.Flush()
 	should.Nil(stream.Error)
 	should.Equal("a4294967295", buf.String())
-}
+}

+ 2 - 2
value_tests/invalid_test.go

@@ -3,11 +3,11 @@ package test
 import (
 	"bytes"
 	"encoding/json"
+	"github.com/json-iterator/go"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
 	"io"
 	"testing"
-	"github.com/json-iterator/go"
 )
 
 func Test_missing_object_end(t *testing.T) {
@@ -223,4 +223,4 @@ func Test_EmptyInput(t *testing.T) {
 	if err == nil {
 		t.Errorf("Expected error")
 	}
-}
+}

+ 5 - 5
value_tests/map_test.go

@@ -1,8 +1,8 @@
 package test
 
 import (
-	"math/big"
 	"encoding/json"
+	"math/big"
 )
 
 func init() {
@@ -26,16 +26,16 @@ func init() {
 		},
 		nilMap,
 		&nilMap,
-		map[string]*json.RawMessage{"hello":pRawMessage(json.RawMessage("[]"))},
+		map[string]*json.RawMessage{"hello": pRawMessage(json.RawMessage("[]"))},
 	)
 	unmarshalCases = append(unmarshalCases, unmarshalCase{
-		ptr: (*map[string]string)(nil),
+		ptr:   (*map[string]string)(nil),
 		input: `{"k\"ey": "val"}`,
 	}, unmarshalCase{
-		ptr: (*map[string]string)(nil),
+		ptr:   (*map[string]string)(nil),
 		input: `null`,
 	}, unmarshalCase{
-		ptr: (*map[string]*json.RawMessage)(nil),
+		ptr:   (*map[string]*json.RawMessage)(nil),
 		input: "{\"test\":[{\"key\":\"value\"}]}",
 	})
 }

+ 5 - 6
value_tests/marshaler_test.go

@@ -1,8 +1,8 @@
 package test
 
 import (
-	"encoding/json"
 	"encoding"
+	"encoding/json"
 )
 
 func init() {
@@ -17,20 +17,20 @@ func init() {
 		tmOfStructInt{},
 		&tm2,
 		map[tmOfStruct]int{
-			tmOfStruct{}: 100,
+			{}: 100,
 		},
 		map[*tmOfStruct]int{
-			&tmOfStruct{}: 100,
+			{}: 100,
 		},
 		map[encoding.TextMarshaler]int{
 			tm1: 100,
 		},
 	)
 	unmarshalCases = append(unmarshalCases, unmarshalCase{
-		ptr: (*tmOfMap)(nil),
+		ptr:   (*tmOfMap)(nil),
 		input: `"{1:2}"`,
 	}, unmarshalCase{
-		ptr: (*tmOfMapPtr)(nil),
+		ptr:   (*tmOfMapPtr)(nil),
 		input: `"{1:2}"`,
 	})
 }
@@ -47,7 +47,6 @@ func (q *jmOfStruct) UnmarshalJSON(value []byte) error {
 	return nil
 }
 
-
 type tmOfStruct struct {
 	F2 chan []byte
 }

+ 1 - 1
value_tests/raw_message_test.go

@@ -7,7 +7,7 @@ func init() {
 		json.RawMessage("{}"),
 	)
 	unmarshalCases = append(unmarshalCases, unmarshalCase{
-		ptr: (*json.RawMessage)(nil),
+		ptr:   (*json.RawMessage)(nil),
 		input: `[1,2,3]`,
 	})
 }

+ 2 - 2
value_tests/string_test.go

@@ -1,9 +1,9 @@
 package test
 
 import (
-	"testing"
-	"github.com/json-iterator/go"
 	"encoding/json"
+	"github.com/json-iterator/go"
+	"testing"
 	"unicode/utf8"
 )
 

+ 2 - 2
value_tests/struct_test.go

@@ -1,9 +1,9 @@
 package test
 
 import (
-	"time"
-	"encoding/json"
 	"bytes"
+	"encoding/json"
+	"time"
 )
 
 func init() {

+ 8 - 8
value_tests/value_test.go

@@ -1,18 +1,18 @@
 package test
 
 import (
-	"testing"
 	"encoding/json"
-	"github.com/stretchr/testify/require"
-	"github.com/json-iterator/go"
 	"fmt"
+	"github.com/json-iterator/go"
+	"github.com/stretchr/testify/require"
 	"github.com/v2pro/plz/reflect2"
+	"testing"
 )
 
 type unmarshalCase struct {
-	obj func() interface{}
-	ptr interface{}
-	input string
+	obj      func() interface{}
+	ptr      interface{}
+	input    string
 	selected bool
 }
 
@@ -22,7 +22,7 @@ var marshalCases = []interface{}{
 	nil,
 }
 
-type selectedMarshalCase struct  {
+type selectedMarshalCase struct {
 	marshalCase interface{}
 }
 
@@ -77,4 +77,4 @@ func Test_marshal(t *testing.T) {
 			should.Equal(string(output1), string(output2))
 		})
 	}
-}
+}