gofmt
diff --git a/go_below_17.go b/go_below_17.go
index 8114231..65a93c8 100644
--- a/go_below_17.go
+++ b/go_below_17.go
@@ -6,4 +6,4 @@
func resolveTypeOff(rtype unsafe.Pointer, off int32) unsafe.Pointer {
return nil
-}
\ No newline at end of file
+}
diff --git a/reflect2.go b/reflect2.go
index feabb61..25890b6 100644
--- a/reflect2.go
+++ b/reflect2.go
@@ -1,9 +1,9 @@
package reflect2
import (
+ "github.com/modern-go/concurrent"
"reflect"
"unsafe"
- "github.com/modern-go/concurrent"
)
type Type interface {
@@ -136,7 +136,7 @@
func (cfg Config) Froze() *frozenConfig {
return &frozenConfig{
useSafeImplementation: cfg.UseSafeImplementation,
- cache: concurrent.NewMap(),
+ cache: concurrent.NewMap(),
}
}
@@ -279,4 +279,4 @@
func NoEscape(p unsafe.Pointer) unsafe.Pointer {
x := uintptr(p)
return unsafe.Pointer(x ^ 0)
-}
\ No newline at end of file
+}
diff --git a/reflect2_kind.go b/reflect2_kind.go
index f13cbe1..62f299e 100644
--- a/reflect2_kind.go
+++ b/reflect2_kind.go
@@ -11,20 +11,20 @@
}
var kindTypes = map[reflect.Kind]Type{
- reflect.Bool: TypeOf(true),
- reflect.Uint8: TypeOf(uint8(0)),
- reflect.Int8: TypeOf(int8(0)),
- reflect.Uint16: TypeOf(uint16(0)),
- reflect.Int16: TypeOf(int16(0)),
- reflect.Uint32: TypeOf(uint32(0)),
- reflect.Int32: TypeOf(int32(0)),
- reflect.Uint64: TypeOf(uint64(0)),
- reflect.Int64: TypeOf(int64(0)),
- reflect.Uint: TypeOf(uint(0)),
- reflect.Int: TypeOf(int(0)),
- reflect.Float32: TypeOf(float32(0)),
- reflect.Float64: TypeOf(float64(0)),
- reflect.Uintptr: TypeOf(uintptr(0)),
- reflect.String: TypeOf(""),
+ reflect.Bool: TypeOf(true),
+ reflect.Uint8: TypeOf(uint8(0)),
+ reflect.Int8: TypeOf(int8(0)),
+ reflect.Uint16: TypeOf(uint16(0)),
+ reflect.Int16: TypeOf(int16(0)),
+ reflect.Uint32: TypeOf(uint32(0)),
+ reflect.Int32: TypeOf(int32(0)),
+ reflect.Uint64: TypeOf(uint64(0)),
+ reflect.Int64: TypeOf(int64(0)),
+ reflect.Uint: TypeOf(uint(0)),
+ reflect.Int: TypeOf(int(0)),
+ reflect.Float32: TypeOf(float32(0)),
+ reflect.Float64: TypeOf(float64(0)),
+ reflect.Uintptr: TypeOf(uintptr(0)),
+ reflect.String: TypeOf(""),
reflect.UnsafePointer: TypeOf(unsafe.Pointer(nil)),
-}
\ No newline at end of file
+}
diff --git a/safe_field.go b/safe_field.go
index f68de45..d4ba1f4 100644
--- a/safe_field.go
+++ b/safe_field.go
@@ -55,4 +55,4 @@
func (field *safeField) UnsafeGet(obj unsafe.Pointer) unsafe.Pointer {
panic("does not support unsafe operation")
-}
\ No newline at end of file
+}
diff --git a/safe_map.go b/safe_map.go
index 6a1ba23..8836220 100644
--- a/safe_map.go
+++ b/safe_map.go
@@ -76,8 +76,8 @@
}
type safeMapIterator struct {
- i int
- m reflect.Value
+ i int
+ m reflect.Value
keys []reflect.Value
}
@@ -98,4 +98,4 @@
func (iter *safeMapIterator) UnsafeNext() (unsafe.Pointer, unsafe.Pointer) {
panic("does not support unsafe operation")
-}
\ No newline at end of file
+}
diff --git a/safe_slice.go b/safe_slice.go
index 7e348c1..bcce6fd 100644
--- a/safe_slice.go
+++ b/safe_slice.go
@@ -89,4 +89,4 @@
func (type2 *safeSliceType) UnsafeCap(ptr unsafe.Pointer) int {
panic("does not support unsafe operation")
-}
\ No newline at end of file
+}
diff --git a/safe_struct.go b/safe_struct.go
index 7333d3e..e5fb9b3 100644
--- a/safe_struct.go
+++ b/safe_struct.go
@@ -26,4 +26,4 @@
panic("field match condition not found in " + type2.Type.String())
}
return &safeField{StructField: field}
-}
\ No newline at end of file
+}
diff --git a/safe_type.go b/safe_type.go
index 3cd6331..ee4e7bb 100644
--- a/safe_type.go
+++ b/safe_type.go
@@ -75,4 +75,4 @@
func (type2 *safeType) AssignableTo(anotherType Type) bool {
return type2.Type1().AssignableTo(anotherType.Type1())
-}
\ No newline at end of file
+}
diff --git a/test15/map_test.go b/test15/map_test.go
index 11b3964..fc389ac 100644
--- a/test15/map_test.go
+++ b/test15/map_test.go
@@ -1,8 +1,8 @@
package test
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_map(t *testing.T) {
@@ -15,4 +15,4 @@
if m[1] != 1 {
t.Fail()
}
-}
\ No newline at end of file
+}
diff --git a/tests/array_test.go b/tests/array_test.go
index 8c91098..fbacb4f 100644
--- a/tests/array_test.go
+++ b/tests/array_test.go
@@ -1,8 +1,8 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_array(t *testing.T) {
@@ -30,7 +30,7 @@
t.Run("GetIndex", testOp(func(api reflect2.API) interface{} {
obj := [2]int{1, 2}
valType := api.TypeOf(obj).(reflect2.ArrayType)
- return []interface{} {
+ return []interface{}{
valType.GetIndex(&obj, 0),
valType.GetIndex(&obj, 1),
}
diff --git a/tests/int_test.go b/tests/int_test.go
index 7fd60e4..2cb2c16 100644
--- a/tests/int_test.go
+++ b/tests/int_test.go
@@ -1,12 +1,12 @@
package tests
import (
- "testing"
+ "context"
"github.com/modern-go/reflect2"
"github.com/modern-go/test"
- "unsafe"
"github.com/modern-go/test/must"
- "context"
+ "testing"
+ "unsafe"
)
func Test_int(t *testing.T) {
diff --git a/tests/map_elem_array_test.go b/tests/map_elem_array_test.go
index 99a0b82..11e6101 100644
--- a/tests/map_elem_array_test.go
+++ b/tests/map_elem_array_test.go
@@ -1,8 +1,8 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_map_elem_array(t *testing.T) {
diff --git a/tests/map_elem_bytes_test.go b/tests/map_elem_bytes_test.go
index a78f91e..61dfe18 100644
--- a/tests/map_elem_bytes_test.go
+++ b/tests/map_elem_bytes_test.go
@@ -1,11 +1,11 @@
package tests
import (
- "testing"
+ "context"
"github.com/modern-go/reflect2"
"github.com/modern-go/test"
"github.com/modern-go/test/must"
- "context"
+ "testing"
"unsafe"
)
diff --git a/tests/map_elem_eface_test.go b/tests/map_elem_eface_test.go
index e60a157..80c7a64 100644
--- a/tests/map_elem_eface_test.go
+++ b/tests/map_elem_eface_test.go
@@ -1,12 +1,12 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
"github.com/modern-go/test/must"
+ "testing"
- "github.com/modern-go/test"
"context"
+ "github.com/modern-go/test"
)
func Test_map_elem_eface(t *testing.T) {
@@ -53,4 +53,4 @@
must.Pass(!iter.HasNext(), "api", api)
return []interface{}{key1, elem1}
}))
-}
\ No newline at end of file
+}
diff --git a/tests/map_elem_map_test.go b/tests/map_elem_map_test.go
index 3cc4dfe..21c2b4c 100644
--- a/tests/map_elem_map_test.go
+++ b/tests/map_elem_map_test.go
@@ -1,8 +1,8 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_map_elem_map(t *testing.T) {
@@ -15,9 +15,9 @@
t.Run("SetIndex", testOp(func(api reflect2.API) interface{} {
obj := map[int]map[int]int{}
valType := api.TypeOf(obj).(reflect2.MapType)
- valType.SetIndex(&obj, pInt(2), pMap(map[int]int{4:4}))
- valType.SetIndex(&obj, pInt(3), pMap(map[int]int{9:9}))
+ valType.SetIndex(&obj, pInt(2), pMap(map[int]int{4: 4}))
+ valType.SetIndex(&obj, pInt(3), pMap(map[int]int{9: 9}))
valType.SetIndex(&obj, pInt(3), pMap(nil))
return obj
}))
-}
\ No newline at end of file
+}
diff --git a/tests/map_elem_struct_test.go b/tests/map_elem_struct_test.go
index 2aea31f..9135dd5 100644
--- a/tests/map_elem_struct_test.go
+++ b/tests/map_elem_struct_test.go
@@ -1,8 +1,8 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
"time"
)
diff --git a/tests/map_key_eface_test.go b/tests/map_key_eface_test.go
index 8c1dc23..3d1b0b4 100644
--- a/tests/map_key_eface_test.go
+++ b/tests/map_key_eface_test.go
@@ -1,9 +1,9 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
"github.com/modern-go/test/must"
+ "testing"
)
func Test_map_key_eface(t *testing.T) {
diff --git a/tests/map_key_iface_test.go b/tests/map_key_iface_test.go
index 245e494..35afac5 100644
--- a/tests/map_key_iface_test.go
+++ b/tests/map_key_iface_test.go
@@ -1,9 +1,9 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
"github.com/modern-go/test/must"
+ "testing"
)
type intError int
diff --git a/tests/map_key_ptr_test.go b/tests/map_key_ptr_test.go
index 230b00b..f9377a0 100644
--- a/tests/map_key_ptr_test.go
+++ b/tests/map_key_ptr_test.go
@@ -1,13 +1,13 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
- "github.com/modern-go/test/must"
"github.com/modern-go/test"
+ "github.com/modern-go/test/must"
+ "testing"
- "unsafe"
"context"
+ "unsafe"
)
func Test_map_key_ptr(t *testing.T) {
diff --git a/tests/map_test.go b/tests/map_test.go
index 131baa4..5283ed6 100644
--- a/tests/map_test.go
+++ b/tests/map_test.go
@@ -1,14 +1,14 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
"github.com/modern-go/test/must"
+ "testing"
- "github.com/modern-go/test"
- "unsafe"
- "reflect"
"context"
+ "github.com/modern-go/test"
+ "reflect"
+ "unsafe"
)
func Test_map(t *testing.T) {
diff --git a/tests/op_test.go b/tests/op_test.go
index fa3bd45..e7eac46 100644
--- a/tests/op_test.go
+++ b/tests/op_test.go
@@ -4,9 +4,9 @@
"github.com/modern-go/reflect2"
"testing"
- "github.com/modern-go/test/must"
- "github.com/modern-go/test"
"context"
+ "github.com/modern-go/test"
+ "github.com/modern-go/test/must"
)
func testOp(f func(api reflect2.API) interface{}) func(t *testing.T) {
diff --git a/tests/slice_array_test.go b/tests/slice_array_test.go
index 0aae880..0d7274d 100644
--- a/tests/slice_array_test.go
+++ b/tests/slice_array_test.go
@@ -1,8 +1,8 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_slice_array(t *testing.T) {
diff --git a/tests/slice_bytes_test.go b/tests/slice_bytes_test.go
index 6cb7b68..cc9f0c1 100644
--- a/tests/slice_bytes_test.go
+++ b/tests/slice_bytes_test.go
@@ -1,8 +1,8 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_slice_bytes(t *testing.T) {
@@ -15,4 +15,4 @@
valType.SetIndex(&obj, 1, &elem2)
return obj
}))
-}
\ No newline at end of file
+}
diff --git a/tests/slice_eface_test.go b/tests/slice_eface_test.go
index 14774fa..bb0c12b 100644
--- a/tests/slice_eface_test.go
+++ b/tests/slice_eface_test.go
@@ -1,14 +1,14 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
"github.com/modern-go/test"
+ "testing"
- "github.com/modern-go/test/must"
- "unsafe"
- "github.com/modern-go/test/should"
"context"
+ "github.com/modern-go/test/must"
+ "github.com/modern-go/test/should"
+ "unsafe"
)
func Test_slice_eface(t *testing.T) {
diff --git a/tests/slice_iface_test.go b/tests/slice_iface_test.go
index 0a94d79..167e9b0 100644
--- a/tests/slice_iface_test.go
+++ b/tests/slice_iface_test.go
@@ -1,14 +1,14 @@
package tests
import (
- "testing"
- "github.com/modern-go/reflect2"
"errors"
+ "github.com/modern-go/reflect2"
"github.com/modern-go/test"
+ "testing"
- "unsafe"
- "github.com/modern-go/test/must"
"context"
+ "github.com/modern-go/test/must"
+ "unsafe"
)
func Test_slice_iface(t *testing.T) {
diff --git a/tests/slice_map_test.go b/tests/slice_map_test.go
index afb876c..49adc76 100644
--- a/tests/slice_map_test.go
+++ b/tests/slice_map_test.go
@@ -1,27 +1,27 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_slice_map(t *testing.T) {
t.Run("MakeSlice", testOp(func(api reflect2.API) interface{} {
valType := api.TypeOf([]map[int]int{}).(reflect2.SliceType)
obj := valType.MakeSlice(5, 10)
- (*obj.(*[]map[int]int))[0] = map[int]int{1:1}
- (*obj.(*[]map[int]int))[4] = map[int]int{2:2}
+ (*obj.(*[]map[int]int))[0] = map[int]int{1: 1}
+ (*obj.(*[]map[int]int))[4] = map[int]int{2: 2}
return obj
}))
t.Run("SetIndex", testOp(func(api reflect2.API) interface{} {
obj := []map[int]int{{1: 1}, nil}
valType := api.TypeOf(obj).(reflect2.SliceType)
- valType.SetIndex(&obj, 0, &map[int]int{10:10})
- valType.SetIndex(&obj, 1, &map[int]int{2:2})
+ valType.SetIndex(&obj, 0, &map[int]int{10: 10})
+ valType.SetIndex(&obj, 1, &map[int]int{2: 2})
return obj
}))
t.Run("GetIndex", testOp(func(api reflect2.API) interface{} {
- obj := []map[int]int{{1:1}, nil}
+ obj := []map[int]int{{1: 1}, nil}
valType := api.TypeOf(obj).(reflect2.SliceType)
return []interface{}{
valType.GetIndex(&obj, 0),
@@ -30,12 +30,12 @@
}))
t.Run("Append", testOp(func(api reflect2.API) interface{} {
obj := make([]map[int]int, 2, 3)
- obj[0] = map[int]int{1:1}
- obj[1] = map[int]int{2:2}
+ obj[0] = map[int]int{1: 1}
+ obj[1] = map[int]int{2: 2}
valType := api.TypeOf(obj).(reflect2.SliceType)
- valType.Append(&obj, &map[int]int{3:3})
+ valType.Append(&obj, &map[int]int{3: 3})
// will trigger grow
- valType.Append(&obj, &map[int]int{4:4})
+ valType.Append(&obj, &map[int]int{4: 4})
return obj
}))
-}
\ No newline at end of file
+}
diff --git a/tests/slice_ptr_test.go b/tests/slice_ptr_test.go
index bbac7f2..61fefd4 100644
--- a/tests/slice_ptr_test.go
+++ b/tests/slice_ptr_test.go
@@ -1,13 +1,13 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
"github.com/modern-go/test"
+ "testing"
- "unsafe"
- "github.com/modern-go/test/must"
"context"
+ "github.com/modern-go/test/must"
+ "unsafe"
)
func Test_slice_ptr(t *testing.T) {
diff --git a/tests/slice_string_test.go b/tests/slice_string_test.go
index 44bf4ca..5292b31 100644
--- a/tests/slice_string_test.go
+++ b/tests/slice_string_test.go
@@ -1,8 +1,8 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_slice_string(t *testing.T) {
@@ -15,4 +15,4 @@
valType.SetIndex(&obj, 1, &elem2)
return obj
}))
-}
\ No newline at end of file
+}
diff --git a/tests/slice_struct_test.go b/tests/slice_struct_test.go
index 893365d..7f7dd60 100644
--- a/tests/slice_struct_test.go
+++ b/tests/slice_struct_test.go
@@ -1,8 +1,8 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_slice_struct(t *testing.T) {
@@ -50,4 +50,4 @@
valType.SetIndex(&obj, 1, &TestObject{})
return obj
}))
-}
\ No newline at end of file
+}
diff --git a/tests/slice_test.go b/tests/slice_test.go
index 2b5f98d..c982c6c 100644
--- a/tests/slice_test.go
+++ b/tests/slice_test.go
@@ -1,12 +1,12 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
"github.com/modern-go/test"
+ "testing"
- "github.com/modern-go/test/must"
"context"
+ "github.com/modern-go/test/must"
)
func Test_slice(t *testing.T) {
diff --git a/tests/struct_eface_test.go b/tests/struct_eface_test.go
index ce1e997..b7f04fd 100644
--- a/tests/struct_eface_test.go
+++ b/tests/struct_eface_test.go
@@ -1,8 +1,8 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
+ "testing"
)
func Test_struct_eface(t *testing.T) {
@@ -25,4 +25,4 @@
field1 := valType.FieldByName("Field1")
return field1.Get(&obj)
}))
-}
\ No newline at end of file
+}
diff --git a/tests/struct_ptr_test.go b/tests/struct_ptr_test.go
index 889d3af..a8cb7fb 100644
--- a/tests/struct_ptr_test.go
+++ b/tests/struct_ptr_test.go
@@ -3,10 +3,10 @@
import (
"testing"
- "github.com/modern-go/reflect2"
- "github.com/modern-go/test/must"
- "github.com/modern-go/test"
"context"
+ "github.com/modern-go/reflect2"
+ "github.com/modern-go/test"
+ "github.com/modern-go/test/must"
)
func Test_struct_ptr(t *testing.T) {
@@ -22,4 +22,4 @@
valType := reflect2.TypeOf(TestObject{})
must.Equal(TestObject{}, valType.Indirect(&TestObject{}))
}))
-}
\ No newline at end of file
+}
diff --git a/tests/struct_test.go b/tests/struct_test.go
index 4f69aad..35ae84a 100644
--- a/tests/struct_test.go
+++ b/tests/struct_test.go
@@ -1,13 +1,13 @@
package tests
import (
- "testing"
"github.com/modern-go/reflect2"
"github.com/modern-go/test"
+ "testing"
- "unsafe"
- "github.com/modern-go/test/must"
"context"
+ "github.com/modern-go/test/must"
+ "unsafe"
)
func Test_struct(t *testing.T) {
diff --git a/type_map.go b/type_map.go
index 122141f..c75daa6 100644
--- a/type_map.go
+++ b/type_map.go
@@ -1,10 +1,10 @@
package reflect2
import (
- "unsafe"
"reflect"
"runtime"
"strings"
+ "unsafe"
)
// typelinks1 for 1.5 ~ 1.6
diff --git a/unsafe_array.go b/unsafe_array.go
index 924b026..76cbdba 100644
--- a/unsafe_array.go
+++ b/unsafe_array.go
@@ -1,8 +1,8 @@
package reflect2
import (
- "unsafe"
"reflect"
+ "unsafe"
)
type UnsafeArrayType struct {
diff --git a/unsafe_eface.go b/unsafe_eface.go
index 446f420..805010f 100644
--- a/unsafe_eface.go
+++ b/unsafe_eface.go
@@ -1,8 +1,8 @@
package reflect2
import (
- "unsafe"
"reflect"
+ "unsafe"
)
type eface struct {
@@ -56,4 +56,4 @@
func (type2 *UnsafeEFaceType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
return *(*interface{})(ptr)
-}
\ No newline at end of file
+}
diff --git a/unsafe_iface.go b/unsafe_iface.go
index 8f451ca..b601955 100644
--- a/unsafe_iface.go
+++ b/unsafe_iface.go
@@ -1,8 +1,8 @@
package reflect2
import (
- "unsafe"
"reflect"
+ "unsafe"
)
type iface struct {
@@ -61,4 +61,4 @@
return true
}
return false
-}
\ No newline at end of file
+}
diff --git a/unsafe_link.go b/unsafe_link.go
index a25a5f4..57229c8 100644
--- a/unsafe_link.go
+++ b/unsafe_link.go
@@ -67,4 +67,4 @@
// the benefit is to surface this assumption at the call site.)
func arrayAt(p unsafe.Pointer, i int, eltSize uintptr, whySafe string) unsafe.Pointer {
return add(p, uintptr(i)*eltSize, "i < len")
-}
\ No newline at end of file
+}
diff --git a/unsafe_ptr.go b/unsafe_ptr.go
index 843724d..8e5ec9c 100644
--- a/unsafe_ptr.go
+++ b/unsafe_ptr.go
@@ -1,8 +1,8 @@
package reflect2
import (
- "unsafe"
"reflect"
+ "unsafe"
)
type UnsafePtrType struct {
diff --git a/unsafe_slice.go b/unsafe_slice.go
index 5ce85af..1c6d876 100644
--- a/unsafe_slice.go
+++ b/unsafe_slice.go
@@ -1,8 +1,8 @@
package reflect2
import (
- "unsafe"
"reflect"
+ "unsafe"
)
// sliceHeader is a safe version of SliceHeader used within this package.
diff --git a/unsafe_struct.go b/unsafe_struct.go
index f91ef17..804d916 100644
--- a/unsafe_struct.go
+++ b/unsafe_struct.go
@@ -56,4 +56,4 @@
panic("field match condition not found in " + type2.Type.String())
}
return newUnsafeStructField(type2, structField)
-}
\ No newline at end of file
+}
diff --git a/unsafe_type.go b/unsafe_type.go
index e7ad4a6..1394171 100644
--- a/unsafe_type.go
+++ b/unsafe_type.go
@@ -1,8 +1,8 @@
package reflect2
import (
- "unsafe"
"reflect"
+ "unsafe"
)
type unsafeType struct {
@@ -15,7 +15,7 @@
return &unsafeType{
safeType: safeType{
Type: type1,
- cfg: cfg,
+ cfg: cfg,
},
rtype: unpackEFace(type1).data,
ptrRType: unpackEFace(reflect.PtrTo(type1)).data,