mirror of
https://github.com/json-iterator/go.git
synced 2025-04-23 11:37:32 +02:00
gofmt
This commit is contained in:
parent
925df245d3
commit
cfffa29c8a
feature_adapter.gofeature_any_array.gofeature_any_float.gofeature_any_int64.gofeature_any_object.gofeature_any_string.gofeature_any_uint64.gofeature_iter.gofeature_iter_array.gofeature_iter_float.gofeature_iter_int.gofeature_iter_skip.gofeature_reflect.gofeature_reflect_array.gofeature_reflect_map.gofeature_reflect_native.gofeature_reflect_object.gofeature_stream_float.gofeature_stream_int.gojsoniter_adapter_test.gojsoniter_array_test.gojsoniter_bool_test.gojsoniter_customize_test.gojsoniter_demo_test.gojsoniter_find_end_test.gojsoniter_float_test.gojsoniter_int_test.gojsoniter_interface_test.gojsoniter_map_test.gojsoniter_null_test.gojsoniter_object_test.gojsoniter_optional_test.gojsoniter_reflect_native_test.gojsoniter_reflect_struct_test.gojsoniter_reflect_test.gojsoniter_stream_test.gojsoniter_string_test.go
@ -2,11 +2,11 @@ package jsoniter
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"reflect"
|
||||
"errors"
|
||||
"unsafe"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
// Unmarshal adapts to json/encoding Unmarshal API
|
||||
|
@ -1,9 +1,9 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type arrayLazyAny struct {
|
||||
@ -44,7 +44,7 @@ func (any *arrayLazyAny) fillCacheUntil(target int) Any {
|
||||
return any.cache[target]
|
||||
}
|
||||
iter := any.Parse()
|
||||
if (len(any.remaining) == len(any.buf)) {
|
||||
if len(any.remaining) == len(any.buf) {
|
||||
iter.head++
|
||||
c := iter.nextToken()
|
||||
if c != ']' {
|
||||
|
@ -2,8 +2,8 @@ package jsoniter
|
||||
|
||||
import (
|
||||
"io"
|
||||
"unsafe"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type float64LazyAny struct {
|
||||
|
@ -2,8 +2,8 @@ package jsoniter
|
||||
|
||||
import (
|
||||
"io"
|
||||
"unsafe"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type int64LazyAny struct {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type objectLazyAny struct {
|
||||
|
@ -146,7 +146,6 @@ func (any *stringAny) Parse() *Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
func (any *stringAny) ValueType() ValueType {
|
||||
return String
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
"io"
|
||||
)
|
||||
|
||||
|
||||
type uint64LazyAny struct {
|
||||
baseAny
|
||||
buf []byte
|
||||
|
@ -276,4 +276,3 @@ func (iter *Iterator) ReadBase64() (ret []byte) {
|
||||
}
|
||||
return ret[:n]
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ func (iter *Iterator) ReadArray() (ret bool) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (iter *Iterator) ReadArrayCB(callback func(*Iterator) bool) (ret bool) {
|
||||
c := iter.nextToken()
|
||||
if c == '[' {
|
||||
|
@ -2,12 +2,13 @@ package jsoniter
|
||||
|
||||
import (
|
||||
"io"
|
||||
"math/big"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
var floatDigits []int8
|
||||
|
||||
const invalidCharForNumber = int8(-1)
|
||||
const endOfNumber = int8(-2)
|
||||
const dotInNumber = int8(-3)
|
||||
@ -91,14 +92,14 @@ func (iter *Iterator) readPositiveFloat32() (ret float32) {
|
||||
if value > uint64SafeToMultiple10 {
|
||||
return iter.readFloat32SlowPath()
|
||||
}
|
||||
value = (value << 3) + (value << 1) + uint64(ind); // value = value * 10 + ind;
|
||||
value = (value << 3) + (value << 1) + uint64(ind) // value = value * 10 + ind;
|
||||
}
|
||||
if c == '.' {
|
||||
i++
|
||||
decimalPlaces := 0;
|
||||
decimalPlaces := 0
|
||||
for ; i < iter.tail; i++ {
|
||||
c = iter.buf[i]
|
||||
ind := floatDigits[c];
|
||||
ind := floatDigits[c]
|
||||
switch ind {
|
||||
case endOfNumber:
|
||||
if decimalPlaces > 0 && decimalPlaces < len(POW10) {
|
||||
@ -194,14 +195,14 @@ func (iter *Iterator) readPositiveFloat64() (ret float64) {
|
||||
if value > uint64SafeToMultiple10 {
|
||||
return iter.readFloat64SlowPath()
|
||||
}
|
||||
value = (value << 3) + (value << 1) + uint64(ind); // value = value * 10 + ind;
|
||||
value = (value << 3) + (value << 1) + uint64(ind) // value = value * 10 + ind;
|
||||
}
|
||||
if c == '.' {
|
||||
i++
|
||||
decimalPlaces := 0;
|
||||
decimalPlaces := 0
|
||||
for ; i < iter.tail; i++ {
|
||||
c = iter.buf[i]
|
||||
ind := floatDigits[c];
|
||||
ind := floatDigits[c]
|
||||
switch ind {
|
||||
case endOfNumber:
|
||||
if decimalPlaces > 0 && decimalPlaces < len(POW10) {
|
||||
|
@ -194,7 +194,7 @@ func (iter *Iterator) readUint32(c byte) (ret uint32) {
|
||||
}
|
||||
value = (value << 3) + (value << 1) + uint32(ind)
|
||||
}
|
||||
if (!iter.loadMore()) {
|
||||
if !iter.loadMore() {
|
||||
return value
|
||||
}
|
||||
}
|
||||
@ -252,7 +252,7 @@ func (iter *Iterator) readUint64(c byte) (ret uint64) {
|
||||
}
|
||||
value = (value << 3) + (value << 1) + uint64(ind)
|
||||
}
|
||||
if (!iter.loadMore()) {
|
||||
if !iter.loadMore() {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ func (iter *Iterator) ReadBool() (ret bool) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
func (iter *Iterator) SkipAndReturnBytes() []byte {
|
||||
if iter.reader != nil {
|
||||
panic("reader input does not support this api")
|
||||
@ -40,7 +39,6 @@ func (iter *Iterator) SkipAndReturnBytes() []byte {
|
||||
return iter.buf[before:after]
|
||||
}
|
||||
|
||||
|
||||
// Skip skips a json object and positions to relatively the next json object
|
||||
func (iter *Iterator) Skip() {
|
||||
c := iter.nextToken()
|
||||
@ -204,15 +202,15 @@ func (iter *Iterator) skipUntilBreak() {
|
||||
}
|
||||
|
||||
func (iter *Iterator) skipFixedBytes(n int) {
|
||||
iter.head += n;
|
||||
if (iter.head >= iter.tail) {
|
||||
more := iter.head - iter.tail;
|
||||
iter.head += n
|
||||
if iter.head >= iter.tail {
|
||||
more := iter.head - iter.tail
|
||||
if !iter.loadMore() {
|
||||
if more > 0 {
|
||||
iter.reportError("skipFixedBytes", "unexpected end");
|
||||
iter.reportError("skipFixedBytes", "unexpected end")
|
||||
}
|
||||
return
|
||||
}
|
||||
iter.head += more;
|
||||
iter.head += more
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
"encoding/json"
|
||||
"encoding"
|
||||
)
|
||||
|
||||
/*
|
||||
|
@ -1,10 +1,10 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
"reflect"
|
||||
"io"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func decoderOfSlice(typ reflect.Type) (Decoder, error) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
"reflect"
|
||||
"encoding/json"
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type mapDecoder struct {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
"encoding/json"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type stringCodec struct {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"io"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func encoderOfStruct(typ reflect.Type) (Encoder, error) {
|
||||
@ -138,7 +138,7 @@ func EnableUnexportedStructFieldsSupport() {
|
||||
|
||||
func createStructDecoder(typ reflect.Type, fields map[string]*structFieldDecoder) (Decoder, error) {
|
||||
knownHash := map[int32]struct{}{
|
||||
0: struct{}{},
|
||||
0: {},
|
||||
}
|
||||
switch len(fields) {
|
||||
case 0:
|
||||
|
@ -21,7 +21,7 @@ func (stream *Stream) WriteFloat32Lossy(val float32) {
|
||||
val = -val
|
||||
}
|
||||
if val > 0x4ffffff {
|
||||
stream.WriteRaw(strconv.FormatFloat(float64(val), 'f', -1, 32));
|
||||
stream.WriteRaw(strconv.FormatFloat(float64(val), 'f', -1, 32))
|
||||
return
|
||||
}
|
||||
precision := 6
|
||||
@ -53,7 +53,7 @@ func (stream *Stream) WriteFloat64Lossy(val float64) {
|
||||
val = -val
|
||||
}
|
||||
if val > 0x4ffffff {
|
||||
stream.WriteRaw(strconv.FormatFloat(val, 'f', -1, 64));
|
||||
stream.WriteRaw(strconv.FormatFloat(val, 'f', -1, 64))
|
||||
return
|
||||
}
|
||||
precision := 6
|
||||
|
@ -5,7 +5,7 @@ var DIGITS []uint32
|
||||
func init() {
|
||||
DIGITS = make([]uint32, 1000)
|
||||
for i := uint32(0); i < 1000; i++ {
|
||||
DIGITS[i] = (((i / 100) + '0') << 16) + ((((i / 10) % 10) + '0') << 8) + i % 10 + '0';
|
||||
DIGITS[i] = (((i / 100) + '0') << 16) + ((((i / 10) % 10) + '0') << 8) + i%10 + '0'
|
||||
if i < 10 {
|
||||
DIGITS[i] += 2 << 24
|
||||
} else if i < 100 {
|
||||
@ -128,7 +128,7 @@ func (stream *Stream) WriteInt32(nval int32) {
|
||||
stream.ensure(11)
|
||||
n := stream.n
|
||||
var val uint32
|
||||
if (nval < 0) {
|
||||
if nval < 0 {
|
||||
val = uint32(-nval)
|
||||
stream.buf[n] = '-'
|
||||
n++
|
||||
@ -232,7 +232,7 @@ func (stream *Stream) WriteInt64(nval int64) {
|
||||
stream.ensure(20)
|
||||
n := stream.n
|
||||
var val uint64
|
||||
if (nval < 0) {
|
||||
if nval < 0 {
|
||||
val = uint64(-nval)
|
||||
stream.buf[n] = '-'
|
||||
n++
|
||||
@ -244,7 +244,7 @@ func (stream *Stream) WriteInt64(nval int64) {
|
||||
stream.n = writeFirstBuf(stream.buf, DIGITS[val], n)
|
||||
return
|
||||
}
|
||||
r1 := val - q1 * 1000;
|
||||
r1 := val - q1*1000
|
||||
q2 := q1 / 1000
|
||||
if q2 == 0 {
|
||||
n := writeFirstBuf(stream.buf, DIGITS[q1], n)
|
||||
|
@ -1,11 +1,11 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"encoding/json"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go/require"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_new_decoder(t *testing.T) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go/require"
|
||||
"io"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_empty_array(t *testing.T) {
|
||||
@ -117,9 +117,9 @@ func Test_array_lazy_any_get_all(t *testing.T) {
|
||||
func Test_array_wrapper_any_get_all(t *testing.T) {
|
||||
should := require.New(t)
|
||||
any := wrapArray([][]int{
|
||||
[]int{1, 2},
|
||||
[]int{3, 4},
|
||||
[]int{5, 6},
|
||||
{1, 2},
|
||||
{3, 4},
|
||||
{5, 6},
|
||||
})
|
||||
should.Equal("[1,3,5]", any.Get('*', 0).ToString())
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"bytes"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_true(t *testing.T) {
|
||||
@ -38,7 +38,6 @@ func Test_write_true_false(t *testing.T) {
|
||||
should.Equal("truefalse", buf.String())
|
||||
}
|
||||
|
||||
|
||||
func Test_write_val_bool(t *testing.T) {
|
||||
should := require.New(t)
|
||||
buf := &bytes.Buffer{}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go/require"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
"unsafe"
|
||||
"github.com/json-iterator/go/require"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
func Test_customize_type_decoder(t *testing.T) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_bind_api_demo(t *testing.T) {
|
||||
@ -84,4 +84,3 @@ func BenchmarkStdMarshal(b *testing.B) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"github.com/json-iterator/go/require"
|
||||
"io"
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
)
|
||||
|
||||
func Test_string_end(t *testing.T) {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"bytes"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_read_big_float(t *testing.T) {
|
||||
|
@ -3,12 +3,12 @@ package jsoniter
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"io/ioutil"
|
||||
"github.com/json-iterator/go/require"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_read_uint64_invalid(t *testing.T) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"math/big"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_read_map(t *testing.T) {
|
||||
@ -46,7 +46,7 @@ func Test_wrap_map(t *testing.T) {
|
||||
|
||||
func Test_map_wrapper_any_get_all(t *testing.T) {
|
||||
should := require.New(t)
|
||||
any := Wrap(map[string][]int{"Field1": []int{1, 2}})
|
||||
any := Wrap(map[string][]int{"Field1": {1, 2}})
|
||||
should.Equal(`{"Field1":1}`, any.Get('*', 0).ToString())
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"bytes"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_read_null(t *testing.T) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_empty_object(t *testing.T) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_encode_optional_int_pointer(t *testing.T) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_reflect_str(t *testing.T) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"bytes"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_decode_one_field_struct(t *testing.T) {
|
||||
|
@ -3,9 +3,9 @@ package jsoniter
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
"unsafe"
|
||||
"github.com/json-iterator/go/require"
|
||||
)
|
||||
|
||||
func Test_decode_slice(t *testing.T) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package jsoniter
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_writeByte_should_grow_buffer(t *testing.T) {
|
||||
|
@ -3,9 +3,9 @@ package jsoniter
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"github.com/json-iterator/go/require"
|
||||
"fmt"
|
||||
"github.com/json-iterator/go/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_read_normal_string(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user