Kaynağa Gözat

remove reference to v2pro

Tao Wen 7 yıl önce
ebeveyn
işleme
c8eaf46a97

+ 1 - 1
reflect2.go

@@ -3,7 +3,7 @@ package reflect2
 import (
 	"reflect"
 	"unsafe"
-	"github.com/v2pro/plz/concurrent"
+	"github.com/modern-go/concurrent"
 )
 
 type Type interface {

+ 6 - 6
test/int_test.go

@@ -3,10 +3,10 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test"
-	"github.com/v2pro/plz/countlog"
+	"github.com/modern-go/test"
 	"unsafe"
-	"github.com/v2pro/plz/test/must"
+	"github.com/modern-go/test/must"
+	"context"
 )
 
 func Test_int(t *testing.T) {
@@ -16,17 +16,17 @@ func Test_int(t *testing.T) {
 		*obj.(*int) = 100
 		return obj
 	}))
-	t.Run("PackEFace", test.Case(func(ctx *countlog.Context) {
+	t.Run("PackEFace", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(1)
 		hundred := 100
 		must.Equal(&hundred, valType.PackEFace(unsafe.Pointer(&hundred)))
 	}))
-	t.Run("Indirect", test.Case(func(ctx *countlog.Context) {
+	t.Run("Indirect", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(1)
 		hundred := 100
 		must.Equal(100, valType.Indirect(&hundred))
 	}))
-	t.Run("Indirect", test.Case(func(ctx *countlog.Context) {
+	t.Run("Indirect", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(1)
 		hundred := 100
 		must.Equal(100, valType.UnsafeIndirect(unsafe.Pointer(&hundred)))

+ 5 - 5
test/map_elem_bytes_test.go

@@ -3,9 +3,9 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test"
-	"github.com/v2pro/plz/countlog"
-	"github.com/v2pro/plz/test/must"
+	"github.com/modern-go/test"
+	"github.com/modern-go/test/must"
+	"context"
 )
 
 func Test_map_elem_bytes(t *testing.T) {
@@ -16,7 +16,7 @@ func Test_map_elem_bytes(t *testing.T) {
 		valType.SetIndex(obj, 3, nil)
 		return obj
 	}))
-	t.Run("UnsafeSetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeSetIndex", test.Case(func(ctx context.Context) {
 		obj := map[int][]byte{}
 		valType := reflect2.TypeOf(obj).(reflect2.MapType)
 		hello := []byte("hello")
@@ -25,7 +25,7 @@ func Test_map_elem_bytes(t *testing.T) {
 		must.Equal([]byte("hello"), obj[2])
 		must.Nil(obj[3])
 	}))
-	t.Run("UnsafeGetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeGetIndex", test.Case(func(ctx context.Context) {
 		obj := map[int][]byte{2: []byte("hello")}
 		valType := reflect2.TypeOf(obj).(reflect2.MapType)
 		elem := valType.UnsafeGetIndex(reflect2.PtrOf(obj), reflect2.PtrOf(2))

+ 5 - 4
test/map_elem_eface_test.go

@@ -3,9 +3,10 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test/must"
-	"github.com/v2pro/plz/countlog"
-	"github.com/v2pro/plz/test"
+	"github.com/modern-go/test/must"
+
+	"github.com/modern-go/test"
+	"context"
 )
 
 func Test_map_elem_eface(t *testing.T) {
@@ -25,7 +26,7 @@ func Test_map_elem_eface(t *testing.T) {
 			valType.GetIndex(obj, 0),
 		}
 	}))
-	t.Run("TryGetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("TryGetIndex", test.Case(func(ctx context.Context) {
 		obj := map[int]interface{}{3: 9, 2: nil}
 		valType := reflect2.TypeOf(obj).(reflect2.MapType)
 		elem, found := valType.TryGetIndex(obj, 3)

+ 1 - 1
test/map_key_eface_test.go

@@ -3,7 +3,7 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test/must"
+	"github.com/modern-go/test/must"
 )
 
 func Test_map_key_eface(t *testing.T) {

+ 1 - 1
test/map_key_iface_test.go

@@ -3,7 +3,7 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test/must"
+	"github.com/modern-go/test/must"
 )
 
 type intError int

+ 5 - 4
test/map_key_ptr_test.go

@@ -3,10 +3,11 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test/must"
-	"github.com/v2pro/plz/test"
-	"github.com/v2pro/plz/countlog"
+	"github.com/modern-go/test/must"
+	"github.com/modern-go/test"
+
 	"unsafe"
+	"context"
 )
 
 func Test_map_key_ptr(t *testing.T) {
@@ -22,7 +23,7 @@ func Test_map_key_ptr(t *testing.T) {
 		//valType.SetIndex(obj, nil, 9)
 		return obj[pInt(2)]
 	}))
-	t.Run("UnsafeSetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeSetIndex", test.Case(func(ctx context.Context) {
 		obj := map[*int]int{}
 		valType := reflect2.TypeOf(obj).(reflect2.MapType)
 		v := pInt(2)

+ 9 - 8
test/map_test.go

@@ -3,11 +3,12 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test/must"
-	"github.com/v2pro/plz/countlog"
-	"github.com/v2pro/plz/test"
+	"github.com/modern-go/test/must"
+
+	"github.com/modern-go/test"
 	"unsafe"
 	"reflect"
+	"context"
 )
 
 func Test_map(t *testing.T) {
@@ -35,13 +36,13 @@ func Test_map(t *testing.T) {
 		m[3] = 9
 		return m
 	}))
-	t.Run("UnsafeMakeMap", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeMakeMap", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(map[int]int{}).(reflect2.MapType)
 		m := *(*map[int]int)(valType.UnsafeMakeMap(0))
 		m[2] = 4
 		m[3] = 9
 	}))
-	t.Run("PackEFace", test.Case(func(ctx *countlog.Context) {
+	t.Run("PackEFace", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(map[int]int{}).(reflect2.MapType)
 		m := valType.UnsafeMakeMap(0)
 		must.Equal(&map[int]int{}, valType.PackEFace(unsafe.Pointer(m)))
@@ -58,7 +59,7 @@ func Test_map(t *testing.T) {
 		must.Equal(4, obj[2])
 		return obj
 	}))
-	t.Run("UnsafeSetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeSetIndex", test.Case(func(ctx context.Context) {
 		obj := map[int]int{}
 		valType := reflect2.TypeOf(obj).(reflect2.MapType)
 		valType.UnsafeSetIndex(unsafe.Pointer(&obj), reflect2.PtrOf(2), reflect2.PtrOf(4))
@@ -72,7 +73,7 @@ func Test_map(t *testing.T) {
 			valType.GetIndex(&obj, pInt(0)).(*int),
 		}
 	}))
-	t.Run("UnsafeGetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeGetIndex", test.Case(func(ctx context.Context) {
 		obj := map[int]int{3: 9, 2: 4}
 		valType := reflect2.TypeOf(obj).(reflect2.MapType)
 		elem := valType.UnsafeGetIndex(unsafe.Pointer(&obj), reflect2.PtrOf(3))
@@ -87,7 +88,7 @@ func Test_map(t *testing.T) {
 		must.Pass(!iter.HasNext(), "api", api)
 		return []interface{}{key1, elem1}
 	}))
-	t.Run("UnsafeIterate", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeIterate", test.Case(func(ctx context.Context) {
 		obj := map[int]int{2: 4}
 		valType := reflect2.TypeOf(obj).(reflect2.MapType)
 		iter := valType.UnsafeIterate(unsafe.Pointer(&obj))

+ 5 - 4
test/op_test.go

@@ -3,13 +3,14 @@ package test
 import (
 	"github.com/modern-go/reflect2"
 	"testing"
-	"github.com/v2pro/plz/countlog"
-	"github.com/v2pro/plz/test/must"
-	"github.com/v2pro/plz/test"
+
+	"github.com/modern-go/test/must"
+	"github.com/modern-go/test"
+	"context"
 )
 
 func testOp(f func(api reflect2.API) interface{}) func(t *testing.T) {
-	return test.Case(func(ctx *countlog.Context) {
+	return test.Case(func(ctx context.Context) {
 		unsafeResult := f(reflect2.ConfigUnsafe)
 		safeResult := f(reflect2.ConfigSafe)
 		must.Equal(safeResult, unsafeResult)

+ 8 - 7
test/slice_eface_test.go

@@ -3,12 +3,13 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test"
-	"github.com/v2pro/plz/countlog"
-	"github.com/v2pro/plz/test/must"
+	"github.com/modern-go/test"
+
+	"github.com/modern-go/test/must"
 	"unsafe"
-	"github.com/v2pro/plz/test/should"
+	"github.com/modern-go/test/should"
 	"fmt"
+	"context"
 )
 
 func Test_slice_eface(t *testing.T) {
@@ -28,7 +29,7 @@ func Test_slice_eface(t *testing.T) {
 		valType.SetIndex(obj, 1, &elem1)
 		return obj
 	}))
-	t.Run("UnsafeSetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeSetIndex", test.Case(func(ctx context.Context) {
 		obj := []interface{}{1, 2}
 		valType := reflect2.TypeOf(obj).(reflect2.SliceType)
 		var elem0 interface{} = 100
@@ -46,7 +47,7 @@ func Test_slice_eface(t *testing.T) {
 			valType.GetIndex(obj, 1),
 		}
 	}))
-	t.Run("UnsafeGetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeGetIndex", test.Case(func(ctx context.Context) {
 		obj := []interface{}{1, nil}
 		valType := reflect2.TypeOf(obj).(reflect2.SliceType)
 		elem0 := valType.UnsafeGetIndex(reflect2.PtrOf(obj), 0)
@@ -62,7 +63,7 @@ func Test_slice_eface(t *testing.T) {
 		valType.Append(&obj, 4)
 		return obj
 	}))
-	t.Run("UnsafeAppend", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeAppend", test.Case(func(ctx context.Context) {
 		obj := make([]interface{}, 2, 3)
 		obj[0] = 1
 		obj[1] = 2

+ 7 - 6
test/slice_iface_test.go

@@ -4,10 +4,11 @@ import (
 	"testing"
 	"github.com/modern-go/reflect2"
 	"errors"
-	"github.com/v2pro/plz/test"
-	"github.com/v2pro/plz/countlog"
+	"github.com/modern-go/test"
+
 	"unsafe"
-	"github.com/v2pro/plz/test/must"
+	"github.com/modern-go/test/must"
+	"context"
 )
 
 func Test_slice_iface(t *testing.T) {
@@ -29,7 +30,7 @@ func Test_slice_iface(t *testing.T) {
 		valType.SetIndex(&obj, 1, pError("world"))
 		return obj
 	}))
-	t.Run("UnsafeSetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeSetIndex", test.Case(func(ctx context.Context) {
 		obj := []error{errors.New("hello"), nil}
 		valType := reflect2.TypeOf(obj).(reflect2.SliceType)
 		elem0 := errors.New("hi")
@@ -46,7 +47,7 @@ func Test_slice_iface(t *testing.T) {
 			valType.GetIndex(&obj, 1),
 		}
 	}))
-	t.Run("UnsafeGetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeGetIndex", test.Case(func(ctx context.Context) {
 		obj := []error{errors.New("hello"), nil}
 		valType := reflect2.TypeOf(obj).(reflect2.SliceType)
 		elem0 := valType.UnsafeGetIndex(reflect2.PtrOf(obj), 0)
@@ -63,7 +64,7 @@ func Test_slice_iface(t *testing.T) {
 		valType.Append(ptr, pError("4"))
 		return ptr
 	}))
-	t.Run("UnsafeAppend", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeAppend", test.Case(func(ctx context.Context) {
 		obj := make([]error, 2, 3)
 		obj[0] = errors.New("1")
 		obj[1] = errors.New("2")

+ 5 - 4
test/slice_ptr_test.go

@@ -3,10 +3,11 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test"
-	"github.com/v2pro/plz/countlog"
+	"github.com/modern-go/test"
+
 	"unsafe"
-	"github.com/v2pro/plz/test/must"
+	"github.com/modern-go/test/must"
+	"context"
 )
 
 func Test_slice_ptr(t *testing.T) {
@@ -27,7 +28,7 @@ func Test_slice_ptr(t *testing.T) {
 		valType.SetIndex(obj, 1, pInt(3))
 		return obj
 	}))
-	t.Run("UnsafeSetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeSetIndex", test.Case(func(ctx context.Context) {
 		obj := []*int{pInt(1), nil}
 		valType := reflect2.TypeOf(obj).(reflect2.SliceType)
 		valType.UnsafeSetIndex(reflect2.PtrOf(obj), 0, unsafe.Pointer(pInt(2)))

+ 8 - 7
test/slice_test.go

@@ -3,9 +3,10 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test"
-	"github.com/v2pro/plz/countlog"
-	"github.com/v2pro/plz/test/must"
+	"github.com/modern-go/test"
+
+	"github.com/modern-go/test/must"
+	"context"
 )
 
 func Test_slice(t *testing.T) {
@@ -48,7 +49,7 @@ func Test_slice(t *testing.T) {
 		obj[4] = 20
 		return obj
 	}))
-	t.Run("UnsafeMakeSlice", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeMakeSlice", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf([]int{}).(reflect2.SliceType)
 		obj := valType.UnsafeMakeSlice(5, 10)
 		must.Equal(&[]int{0, 0, 0, 0, 0}, valType.PackEFace(obj))
@@ -60,7 +61,7 @@ func Test_slice(t *testing.T) {
 		valType.SetIndex(&obj, 1, pInt(20))
 		return obj
 	}))
-	t.Run("UnsafeSetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeSetIndex", test.Case(func(ctx context.Context) {
 		obj := []int{1, 2}
 		valType := reflect2.TypeOf(obj).(reflect2.SliceType)
 		valType.UnsafeSetIndex(reflect2.PtrOf(obj), 0, reflect2.PtrOf(100))
@@ -74,7 +75,7 @@ func Test_slice(t *testing.T) {
 			valType.GetIndex(&obj, 1).(*int),
 		}
 	}))
-	t.Run("UnsafeGetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeGetIndex", test.Case(func(ctx context.Context) {
 		obj := []int{1, 2}
 		valType := reflect2.TypeOf(obj).(reflect2.SliceType)
 		elem0 := valType.UnsafeGetIndex(reflect2.PtrOf(obj), 0)
@@ -93,7 +94,7 @@ func Test_slice(t *testing.T) {
 		valType.Append(ptr, pInt(4))
 		return ptr
 	}))
-	t.Run("UnsafeAppend", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeAppend", test.Case(func(ctx context.Context) {
 		obj := make([]int, 2, 3)
 		obj[0] = 1
 		obj[1] = 2

+ 6 - 5
test/struct_ptr_test.go

@@ -2,22 +2,23 @@ package test
 
 import (
 	"testing"
-	"github.com/v2pro/plz/countlog"
+
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test/must"
-	"github.com/v2pro/plz/test"
+	"github.com/modern-go/test/must"
+	"github.com/modern-go/test"
+	"context"
 )
 
 func Test_struct_ptr(t *testing.T) {
 	type TestObject struct {
 		Field1 *int
 	}
-	t.Run("PackEFace", test.Case(func(ctx *countlog.Context) {
+	t.Run("PackEFace", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(TestObject{})
 		ptr := valType.UnsafeNew()
 		must.Equal(&TestObject{}, valType.PackEFace(ptr))
 	}))
-	t.Run("Indirect", test.Case(func(ctx *countlog.Context) {
+	t.Run("Indirect", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(TestObject{})
 		must.Equal(TestObject{}, valType.Indirect(&TestObject{}))
 	}))

+ 8 - 7
test/struct_test.go

@@ -3,10 +3,11 @@ package test
 import (
 	"testing"
 	"github.com/modern-go/reflect2"
-	"github.com/v2pro/plz/test"
-	"github.com/v2pro/plz/countlog"
+	"github.com/modern-go/test"
+
 	"unsafe"
-	"github.com/v2pro/plz/test/must"
+	"github.com/modern-go/test/must"
+	"context"
 )
 
 func Test_struct(t *testing.T) {
@@ -24,12 +25,12 @@ func Test_struct(t *testing.T) {
 		obj.(*TestObject).Field2 = 100
 		return obj
 	}))
-	t.Run("PackEFace", test.Case(func(ctx *countlog.Context) {
+	t.Run("PackEFace", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(TestObject{})
 		ptr := valType.UnsafeNew()
 		must.Equal(&TestObject{}, valType.PackEFace(ptr))
 	}))
-	t.Run("Indirect", test.Case(func(ctx *countlog.Context) {
+	t.Run("Indirect", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(TestObject{})
 		must.Equal(TestObject{}, valType.Indirect(&TestObject{}))
 	}))
@@ -40,7 +41,7 @@ func Test_struct(t *testing.T) {
 		field1.Set(&obj, pInt(100))
 		return obj
 	}))
-	t.Run("UnsafeSetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeSetIndex", test.Case(func(ctx context.Context) {
 		valType := reflect2.TypeOf(TestObject{}).(reflect2.StructType)
 		field1 := valType.FieldByName("Field1")
 		obj := TestObject{}
@@ -53,7 +54,7 @@ func Test_struct(t *testing.T) {
 		field1 := valType.FieldByName("Field1")
 		return field1.Get(&obj)
 	}))
-	t.Run("UnsafeGetIndex", test.Case(func(ctx *countlog.Context) {
+	t.Run("UnsafeGetIndex", test.Case(func(ctx context.Context) {
 		obj := TestObject{Field1: 100}
 		valType := reflect2.TypeOf(obj).(reflect2.StructType)
 		field1 := valType.FieldByName("Field1")