diff --git a/container/garray/garray_normal_any.go b/container/garray/garray_normal_any.go index e43b77d0b..fe43a82ab 100644 --- a/container/garray/garray_normal_any.go +++ b/container/garray/garray_normal_any.go @@ -9,15 +9,15 @@ package garray import ( "bytes" "fmt" + "math" + "sort" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/text/gstr" - "math" - "sort" - "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/grand" ) diff --git a/container/garray/garray_normal_int.go b/container/garray/garray_normal_int.go index 0d4ccaec8..5dacdc95b 100644 --- a/container/garray/garray_normal_int.go +++ b/container/garray/garray_normal_int.go @@ -9,12 +9,12 @@ package garray import ( "bytes" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/json" "math" "sort" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/grand" diff --git a/container/garray/garray_normal_str.go b/container/garray/garray_normal_str.go index 715a74ae8..71a6f2e36 100644 --- a/container/garray/garray_normal_str.go +++ b/container/garray/garray_normal_str.go @@ -8,15 +8,15 @@ package garray import ( "bytes" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/text/gstr" "math" "sort" "strings" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/grand" ) diff --git a/container/garray/garray_sorted_any.go b/container/garray/garray_sorted_any.go index a9db1108e..1b702dec0 100644 --- a/container/garray/garray_sorted_any.go +++ b/container/garray/garray_sorted_any.go @@ -9,16 +9,16 @@ package garray import ( "bytes" "fmt" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/util/gutil" "math" "sort" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/grand" + "github.com/gogf/gf/v2/util/gutil" ) // SortedArray is a golang sorted array with rich features. diff --git a/container/garray/garray_sorted_int.go b/container/garray/garray_sorted_int.go index 0b01eb7cd..fd2730438 100644 --- a/container/garray/garray_sorted_int.go +++ b/container/garray/garray_sorted_int.go @@ -9,10 +9,10 @@ package garray import ( "bytes" "fmt" - "github.com/gogf/gf/v2/internal/json" "math" "sort" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/grand" diff --git a/container/garray/garray_sorted_str.go b/container/garray/garray_sorted_str.go index 3c7e03449..768fec23a 100644 --- a/container/garray/garray_sorted_str.go +++ b/container/garray/garray_sorted_str.go @@ -8,13 +8,13 @@ package garray import ( "bytes" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/text/gstr" "math" "sort" "strings" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/grand" ) diff --git a/container/garray/garray_z_bench_any_test.go b/container/garray/garray_z_bench_any_test.go index 2eca2a91d..b316e23b5 100644 --- a/container/garray/garray_z_bench_any_test.go +++ b/container/garray/garray_z_bench_any_test.go @@ -7,8 +7,9 @@ package garray_test import ( - "github.com/gogf/gf/v2/container/garray" "testing" + + "github.com/gogf/gf/v2/container/garray" ) type anySortedArrayItem struct { diff --git a/container/garray/garray_z_example_any_test.go b/container/garray/garray_z_example_any_test.go index 701c2ac66..a7b914ef5 100644 --- a/container/garray/garray_z_example_any_test.go +++ b/container/garray/garray_z_example_any_test.go @@ -8,9 +8,9 @@ package garray_test import ( "fmt" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" ) func ExampleNew() { diff --git a/container/garray/garray_z_example_int_test.go b/container/garray/garray_z_example_int_test.go index c188e962a..6052ca601 100644 --- a/container/garray/garray_z_example_int_test.go +++ b/container/garray/garray_z_example_int_test.go @@ -8,6 +8,7 @@ package garray_test import ( "fmt" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/internal/json" @@ -144,7 +145,7 @@ func ExampleIntArray_SortFunc() { s := garray.NewIntArrayFrom(g.SliceInt{10, 20, 15, 30}) fmt.Println(s) s.SortFunc(func(v1, v2 int) bool { - //fmt.Println(v1,v2) + // fmt.Println(v1,v2) return v1 > v2 }) fmt.Println(s) diff --git a/container/garray/garray_z_example_sorted_str_test.go b/container/garray/garray_z_example_sorted_str_test.go index 0c9c83a51..37b08ce27 100644 --- a/container/garray/garray_z_example_sorted_str_test.go +++ b/container/garray/garray_z_example_sorted_str_test.go @@ -8,6 +8,7 @@ package garray_test import ( "fmt" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/internal/json" diff --git a/container/garray/garray_z_example_str_test.go b/container/garray/garray_z_example_str_test.go index f07bded82..a7efa9692 100644 --- a/container/garray/garray_z_example_str_test.go +++ b/container/garray/garray_z_example_str_test.go @@ -8,6 +8,7 @@ package garray_test import ( "fmt" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/internal/json" diff --git a/container/garray/garray_z_unit_all_basic_test.go b/container/garray/garray_z_unit_all_basic_test.go index 77e7f9a21..1fff15620 100644 --- a/container/garray/garray_z_unit_all_basic_test.go +++ b/container/garray/garray_z_unit_all_basic_test.go @@ -9,13 +9,13 @@ package garray_test import ( - "github.com/gogf/gf/v2/util/gutil" "strings" "testing" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gutil" ) func Test_Array_Var(t *testing.T) { diff --git a/container/garray/garray_z_unit_normal_any_array_test.go b/container/garray/garray_z_unit_normal_any_array_test.go index f0735b3f6..d1e132174 100644 --- a/container/garray/garray_z_unit_normal_any_array_test.go +++ b/container/garray/garray_z_unit_normal_any_array_test.go @@ -9,12 +9,12 @@ package garray_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" "testing" "time" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" ) @@ -260,7 +260,7 @@ func TestArray_Merge(t *testing.T) { array2 := garray.NewArrayFrom(i2) t.Assert(array1.Merge(array2).Slice(), []interface{}{0, 1, 2, 3, 4, 5, 6, 7}) - //s1 := []string{"a", "b", "c", "d"} + // s1 := []string{"a", "b", "c", "d"} s2 := []string{"e", "f"} i3 := garray.NewIntArrayFrom([]int{1, 2, 3}) i4 := garray.NewArrayFrom([]interface{}{3}) @@ -502,16 +502,16 @@ func TestArray_LockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 3) - //go1 - go a1.LockFunc(func(n1 []interface{}) { //读写锁 - time.Sleep(2 * time.Second) //暂停2秒 + // go1 + go a1.LockFunc(func(n1 []interface{}) { // 读写锁 + time.Sleep(2 * time.Second) // 暂停2秒 n1[2] = "g" ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -519,10 +519,10 @@ func TestArray_LockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertGT(t2-t1, 20) //go1加的读写互斥锁,所go2读的时候被阻塞。 + t.AssertGT(t2-t1, 20) // go1加的读写互斥锁,所go2读的时候被阻塞。 t.Assert(a1.Contains("g"), true) }) } @@ -534,16 +534,16 @@ func TestArray_RLockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 1) - //go1 - go a1.RLockFunc(func(n1 []interface{}) { //读锁 - time.Sleep(2 * time.Second) //暂停1秒 + // go1 + go a1.RLockFunc(func(n1 []interface{}) { // 读锁 + time.Sleep(2 * time.Second) // 暂停1秒 n1[2] = "g" ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -551,10 +551,10 @@ func TestArray_RLockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertLT(t2-t1, 20) //go1加的读锁,所go2读的时候,并没有阻塞。 + t.AssertLT(t2-t1, 20) // go1加的读锁,所go2读的时候,并没有阻塞。 t.Assert(a1.Contains("g"), true) }) } diff --git a/container/garray/garray_z_unit_normal_int_array_test.go b/container/garray/garray_z_unit_normal_int_array_test.go index de097bc49..e8e3b79b3 100644 --- a/container/garray/garray_z_unit_normal_int_array_test.go +++ b/container/garray/garray_z_unit_normal_int_array_test.go @@ -9,15 +9,14 @@ package garray_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" "testing" "time" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_IntArray_Basic(t *testing.T) { @@ -534,16 +533,16 @@ func TestIntArray_LockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 3) - //go1 - go a1.LockFunc(func(n1 []int) { //读写锁 - time.Sleep(2 * time.Second) //暂停2秒 + // go1 + go a1.LockFunc(func(n1 []int) { // 读写锁 + time.Sleep(2 * time.Second) // 暂停2秒 n1[2] = 6 ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -551,10 +550,10 @@ func TestIntArray_LockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertGT(t2-t1, 20) //go1加的读写互斥锁,所go2读的时候被阻塞。 + t.AssertGT(t2-t1, 20) // go1加的读写互斥锁,所go2读的时候被阻塞。 t.Assert(a1.Contains(6), true) }) } @@ -579,16 +578,16 @@ func TestIntArray_RLockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 1) - //go1 - go a1.RLockFunc(func(n1 []int) { //读锁 - time.Sleep(2 * time.Second) //暂停1秒 + // go1 + go a1.RLockFunc(func(n1 []int) { // 读锁 + time.Sleep(2 * time.Second) // 暂停1秒 n1[2] = 6 ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -596,10 +595,10 @@ func TestIntArray_RLockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertLT(t2-t1, 20) //go1加的读锁,所go2读的时候,并没有阻塞。 + t.AssertLT(t2-t1, 20) // go1加的读锁,所go2读的时候,并没有阻塞。 t.Assert(a1.Contains(6), true) }) } @@ -758,7 +757,7 @@ func TestIntArray_UnmarshalValue(t *testing.T) { t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) }) // Map - //gtest.C(t, func(t *gtest.T) { + // gtest.C(t, func(t *gtest.T) { // var v *V // err := gconv.Struct(g.Map{ // "name": "john", @@ -767,7 +766,7 @@ func TestIntArray_UnmarshalValue(t *testing.T) { // t.Assert(err, nil) // t.Assert(v.Name, "john") // t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) - //}) + // }) } func TestIntArray_FilterEmpty(t *testing.T) { diff --git a/container/garray/garray_z_unit_normal_str_array_test.go b/container/garray/garray_z_unit_normal_str_array_test.go index 9cb7b67f6..d5d8bcf6e 100644 --- a/container/garray/garray_z_unit_normal_str_array_test.go +++ b/container/garray/garray_z_unit_normal_str_array_test.go @@ -9,13 +9,13 @@ package garray_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" "strings" "testing" "time" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" ) @@ -534,16 +534,16 @@ func TestStrArray_RLockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 1) - //go1 - go a1.RLockFunc(func(n1 []string) { //读锁 - time.Sleep(2 * time.Second) //暂停1秒 + // go1 + go a1.RLockFunc(func(n1 []string) { // 读锁 + time.Sleep(2 * time.Second) // 暂停1秒 n1[2] = "g" ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -551,10 +551,10 @@ func TestStrArray_RLockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertLT(t2-t1, 20) //go1加的读锁,所go2读的时候,并没有阻塞。 + t.AssertLT(t2-t1, 20) // go1加的读锁,所go2读的时候,并没有阻塞。 t.Assert(a1.Contains("g"), true) }) } @@ -578,16 +578,16 @@ func TestStrArray_LockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 3) - //go1 - go a1.LockFunc(func(n1 []string) { //读写锁 - time.Sleep(2 * time.Second) //暂停2秒 + // go1 + go a1.LockFunc(func(n1 []string) { // 读写锁 + time.Sleep(2 * time.Second) // 暂停2秒 n1[2] = "g" ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -595,10 +595,10 @@ func TestStrArray_LockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertGT(t2-t1, 20) //go1加的读写互斥锁,所go2读的时候被阻塞。 + t.AssertGT(t2-t1, 20) // go1加的读写互斥锁,所go2读的时候被阻塞。 t.Assert(a1.Contains("g"), true) }) } diff --git a/container/garray/garray_z_unit_sorted_any_array_test.go b/container/garray/garray_z_unit_sorted_any_array_test.go index 92e4ed515..1513aa342 100644 --- a/container/garray/garray_z_unit_sorted_any_array_test.go +++ b/container/garray/garray_z_unit_sorted_any_array_test.go @@ -9,16 +9,16 @@ package garray_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gutil" "strings" "testing" "time" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gutil" ) func TestSortedArray_NewSortedArrayFrom(t *testing.T) { @@ -554,16 +554,16 @@ func TestSortedArray_LockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 3) - //go1 - go a1.LockFunc(func(n1 []interface{}) { //读写锁 - time.Sleep(2 * time.Second) //暂停2秒 + // go1 + go a1.LockFunc(func(n1 []interface{}) { // 读写锁 + time.Sleep(2 * time.Second) // 暂停2秒 n1[2] = "g" ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -571,10 +571,10 @@ func TestSortedArray_LockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertGT(t2-t1, 20) //go1加的读写互斥锁,所go2读的时候被阻塞。 + t.AssertGT(t2-t1, 20) // go1加的读写互斥锁,所go2读的时候被阻塞。 t.Assert(a1.Contains("g"), true) }) } @@ -589,16 +589,16 @@ func TestSortedArray_RLockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 3) - //go1 - go a1.RLockFunc(func(n1 []interface{}) { //读写锁 - time.Sleep(2 * time.Second) //暂停2秒 + // go1 + go a1.RLockFunc(func(n1 []interface{}) { // 读写锁 + time.Sleep(2 * time.Second) // 暂停2秒 n1[2] = "g" ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -606,10 +606,10 @@ func TestSortedArray_RLockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertLT(t2-t1, 20) //go1加的读锁,所go2读的时候不会被阻塞。 + t.AssertLT(t2-t1, 20) // go1加的读锁,所go2读的时候不会被阻塞。 t.Assert(a1.Contains("g"), true) }) } diff --git a/container/garray/garray_z_unit_sorted_int_array_test.go b/container/garray/garray_z_unit_sorted_int_array_test.go index b060f4c7d..c653340c6 100644 --- a/container/garray/garray_z_unit_sorted_int_array_test.go +++ b/container/garray/garray_z_unit_sorted_int_array_test.go @@ -9,15 +9,14 @@ package garray_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" "testing" "time" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func TestNewSortedIntArrayFrom(t *testing.T) { @@ -337,7 +336,7 @@ func TestSortedIntArray_Chunk(t *testing.T) { gtest.C(t, func(t *gtest.T) { a1 := []int{1, 2, 3, 4, 5} array1 := garray.NewSortedIntArrayFrom(a1) - ns1 := array1.Chunk(2) //按每几个元素切成一个数组 + ns1 := array1.Chunk(2) // 按每几个元素切成一个数组 ns2 := array1.Chunk(-1) t.Assert(len(ns1), 3) t.Assert(ns1[0], []int{1, 2}) @@ -427,7 +426,7 @@ func TestSortedIntArray_CountValues(t *testing.T) { gtest.C(t, func(t *gtest.T) { a1 := []int{1, 2, 3, 4, 5, 3} array1 := garray.NewSortedIntArrayFrom(a1) - ns1 := array1.CountValues() //按每几个元素切成一个数组 + ns1 := array1.CountValues() // 按每几个元素切成一个数组 t.Assert(len(ns1), 5) t.Assert(ns1[2], 1) t.Assert(ns1[3], 2) @@ -460,16 +459,16 @@ func TestSortedIntArray_LockFunc(t *testing.T) { a1 := garray.NewSortedIntArrayFrom(s1, true) ch1 := make(chan int64, 3) ch2 := make(chan int64, 3) - //go1 - go a1.LockFunc(func(n1 []int) { //读写锁 - time.Sleep(2 * time.Second) //暂停2秒 + // go1 + go a1.LockFunc(func(n1 []int) { // 读写锁 + time.Sleep(2 * time.Second) // 暂停2秒 n1[2] = 6 ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -477,10 +476,10 @@ func TestSortedIntArray_LockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertGT(t2-t1, 20) //go1加的读写互斥锁,所go2读的时候被阻塞。 + t.AssertGT(t2-t1, 20) // go1加的读写互斥锁,所go2读的时候被阻塞。 t.Assert(a1.Contains(6), true) }) } @@ -492,16 +491,16 @@ func TestSortedIntArray_RLockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 1) - //go1 - go a1.RLockFunc(func(n1 []int) { //读锁 - time.Sleep(2 * time.Second) //暂停1秒 + // go1 + go a1.RLockFunc(func(n1 []int) { // 读锁 + time.Sleep(2 * time.Second) // 暂停1秒 n1[2] = 6 ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -509,10 +508,10 @@ func TestSortedIntArray_RLockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertLT(t2-t1, 20) //go1加的读锁,所go2读的时候,并没有阻塞。 + t.AssertLT(t2-t1, 20) // go1加的读锁,所go2读的时候,并没有阻塞。 t.Assert(a1.Contains(6), true) }) } diff --git a/container/garray/garray_z_unit_sorted_str_array_test.go b/container/garray/garray_z_unit_sorted_str_array_test.go index 7da5ecd1f..7625064a1 100644 --- a/container/garray/garray_z_unit_sorted_str_array_test.go +++ b/container/garray/garray_z_unit_sorted_str_array_test.go @@ -9,12 +9,12 @@ package garray_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" "testing" "time" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" ) @@ -479,16 +479,16 @@ func TestSortedStrArray_LockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 3) - //go1 - go a1.LockFunc(func(n1 []string) { //读写锁 - time.Sleep(2 * time.Second) //暂停2秒 + // go1 + go a1.LockFunc(func(n1 []string) { // 读写锁 + time.Sleep(2 * time.Second) // 暂停2秒 n1[2] = "g" ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -496,10 +496,10 @@ func TestSortedStrArray_LockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertGT(t2-t1, 20) //go1加的读写互斥锁,所go2读的时候被阻塞。 + t.AssertGT(t2-t1, 20) // go1加的读写互斥锁,所go2读的时候被阻塞。 t.Assert(a1.Contains("g"), true) }) } @@ -511,16 +511,16 @@ func TestSortedStrArray_RLockFunc(t *testing.T) { ch1 := make(chan int64, 3) ch2 := make(chan int64, 1) - //go1 - go a1.RLockFunc(func(n1 []string) { //读锁 - time.Sleep(2 * time.Second) //暂停1秒 + // go1 + go a1.RLockFunc(func(n1 []string) { // 读锁 + time.Sleep(2 * time.Second) // 暂停1秒 n1[2] = "g" ch2 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) }) - //go2 + // go2 go func() { - time.Sleep(100 * time.Millisecond) //故意暂停0.01秒,等go1执行锁后,再开始执行. + time.Sleep(100 * time.Millisecond) // 故意暂停0.01秒,等go1执行锁后,再开始执行. ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) a1.Len() ch1 <- gconv.Int64(time.Now().UnixNano() / 1000 / 1000) @@ -528,10 +528,10 @@ func TestSortedStrArray_RLockFunc(t *testing.T) { t1 := <-ch1 t2 := <-ch1 - <-ch2 //等待go1完成 + <-ch2 // 等待go1完成 // 防止ci抖动,以豪秒为单位 - t.AssertLT(t2-t1, 20) //go1加的读锁,所go2读的时候,并没有阻塞。 + t.AssertLT(t2-t1, 20) // go1加的读锁,所go2读的时候,并没有阻塞。 t.Assert(a1.Contains("g"), true) }) } diff --git a/container/glist/glist.go b/container/glist/glist.go index 03bfa261b..d3e82a082 100644 --- a/container/glist/glist.go +++ b/container/glist/glist.go @@ -11,10 +11,10 @@ package glist import ( "bytes" "container/list" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/util/gconv" ) type ( diff --git a/container/glist/glist_z_example_test.go b/container/glist/glist_z_example_test.go index 54126b760..25781401a 100644 --- a/container/glist/glist_z_example_test.go +++ b/container/glist/glist_z_example_test.go @@ -9,10 +9,10 @@ package glist_test import ( "container/list" "fmt" - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/glist" + "github.com/gogf/gf/v2/frame/g" ) func ExampleNew() { diff --git a/container/glist/glist_z_unit_test.go b/container/glist/glist_z_unit_test.go index f7d7d2098..edd1f7c4b 100644 --- a/container/glist/glist_z_unit_test.go +++ b/container/glist/glist_z_unit_test.go @@ -8,11 +8,11 @@ package glist import ( "container/list" + "testing" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - - "testing" ) func checkListLen(t *gtest.T, l *List, len int) bool { @@ -46,34 +46,34 @@ func TestVar(t *testing.T) { if v := l.PopBack(); v != 1 { t.Errorf("EXPECT %v, GOT %v", 1, v) } else { - //fmt.Println(v) + // fmt.Println(v) } if v := l.PopBack(); v != 2 { t.Errorf("EXPECT %v, GOT %v", 2, v) } else { - //fmt.Println(v) + // fmt.Println(v) } if v := l.PopBack(); v != nil { t.Errorf("EXPECT %v, GOT %v", nil, v) } else { - //fmt.Println(v) + // fmt.Println(v) } l.PushBack(1) l.PushBack(2) if v := l.PopFront(); v != 1 { t.Errorf("EXPECT %v, GOT %v", 1, v) } else { - //fmt.Println(v) + // fmt.Println(v) } if v := l.PopFront(); v != 2 { t.Errorf("EXPECT %v, GOT %v", 2, v) } else { - //fmt.Println(v) + // fmt.Println(v) } if v := l.PopFront(); v != nil { t.Errorf("EXPECT %v, GOT %v", nil, v) } else { - //fmt.Println(v) + // fmt.Println(v) } } @@ -84,34 +84,34 @@ func TestBasic(t *testing.T) { if v := l.PopBack(); v != 1 { t.Errorf("EXPECT %v, GOT %v", 1, v) } else { - //fmt.Println(v) + // fmt.Println(v) } if v := l.PopBack(); v != 2 { t.Errorf("EXPECT %v, GOT %v", 2, v) } else { - //fmt.Println(v) + // fmt.Println(v) } if v := l.PopBack(); v != nil { t.Errorf("EXPECT %v, GOT %v", nil, v) } else { - //fmt.Println(v) + // fmt.Println(v) } l.PushBack(1) l.PushBack(2) if v := l.PopFront(); v != 1 { t.Errorf("EXPECT %v, GOT %v", 1, v) } else { - //fmt.Println(v) + // fmt.Println(v) } if v := l.PopFront(); v != 2 { t.Errorf("EXPECT %v, GOT %v", 2, v) } else { - //fmt.Println(v) + // fmt.Println(v) } if v := l.PopFront(); v != nil { t.Errorf("EXPECT %v, GOT %v", nil, v) } else { - //fmt.Println(v) + // fmt.Println(v) } } @@ -221,13 +221,13 @@ func checkList(t *gtest.T, l *List, es []interface{}) { i++ } - //for e := l.Front(); e != nil; e = e.Next() { + // for e := l.Front(); e != nil; e = e.Next() { // le := e.Value.(int) // if le != es[i] { // t.Errorf("elt[%d].Value() = %v, want %v", i, le, es[i]) // } // i++ - //} + // } } func TestExtending(t *testing.T) { @@ -283,11 +283,11 @@ func TestRemove(t *testing.T) { e1 := l.PushBack(1) e2 := l.PushBack(2) checkListPointers(t, l, []*Element{e1, e2}) - //e := l.Front() - //l.Remove(e) - //checkListPointers(t, l, []*Element{e2}) - //l.Remove(e) - //checkListPointers(t, l, []*Element{e2}) + // e := l.Front() + // l.Remove(e) + // checkListPointers(t, l, []*Element{e2}) + // l.Remove(e) + // checkListPointers(t, l, []*Element{e2}) }) } @@ -322,12 +322,12 @@ func TestIssue6349(t *testing.T) { if e.Value != 1 { t.Errorf("e.value = %d, want 1", e.Value) } - //if e.Next() != nil { + // if e.Next() != nil { // t.Errorf("e.Next() != nil") - //} - //if e.Prev() != nil { + // } + // if e.Prev() != nil { // t.Errorf("e.Prev() != nil") - //} + // } } func TestMove(t *testing.T) { @@ -474,7 +474,7 @@ func TestList_PopBacks(t *testing.T) { i1 := l.PopBacks(2) t.Assert(i1, []interface{}{1, 2}) - l.PushBacks(a2) //4.3,a,c,b,e + l.PushBacks(a2) // 4.3,a,c,b,e i1 = l.PopBacks(3) t.Assert(i1, []interface{}{"e", "b", "c"}) }) diff --git a/container/gmap/gmap_hash_any_any_map.go b/container/gmap/gmap_hash_any_any_map.go index 1d56eb859..a1f4b3230 100644 --- a/container/gmap/gmap_hash_any_any_map.go +++ b/container/gmap/gmap_hash_any_any_map.go @@ -7,14 +7,11 @@ package gmap import ( - "github.com/gogf/gf/v2/internal/json" - - "github.com/gogf/gf/v2/internal/empty" - - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/util/gconv" ) type AnyAnyMap struct { diff --git a/container/gmap/gmap_hash_int_any_map.go b/container/gmap/gmap_hash_int_any_map.go index 4d2986eb8..15a0953e0 100644 --- a/container/gmap/gmap_hash_int_any_map.go +++ b/container/gmap/gmap_hash_int_any_map.go @@ -8,11 +8,9 @@ package gmap import ( - "github.com/gogf/gf/v2/internal/json" - - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/container/gmap/gmap_hash_int_int_map.go b/container/gmap/gmap_hash_int_int_map.go index e82593db2..36e2f74fb 100644 --- a/container/gmap/gmap_hash_int_int_map.go +++ b/container/gmap/gmap_hash_int_int_map.go @@ -7,12 +7,10 @@ package gmap import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/internal/empty" - + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/util/gconv" ) type IntIntMap struct { diff --git a/container/gmap/gmap_hash_int_str_map.go b/container/gmap/gmap_hash_int_str_map.go index 7be2376ca..94a026ef8 100644 --- a/container/gmap/gmap_hash_int_str_map.go +++ b/container/gmap/gmap_hash_int_str_map.go @@ -7,10 +7,8 @@ package gmap import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/empty" - + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/container/gmap/gmap_hash_str_any_map.go b/container/gmap/gmap_hash_str_any_map.go index 832fbdd5d..8846a2971 100644 --- a/container/gmap/gmap_hash_str_any_map.go +++ b/container/gmap/gmap_hash_str_any_map.go @@ -8,11 +8,9 @@ package gmap import ( - "github.com/gogf/gf/v2/internal/json" - - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/container/gmap/gmap_hash_str_int_map.go b/container/gmap/gmap_hash_str_int_map.go index f068940d5..a6c7fc773 100644 --- a/container/gmap/gmap_hash_str_int_map.go +++ b/container/gmap/gmap_hash_str_int_map.go @@ -8,9 +8,8 @@ package gmap import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/container/gmap/gmap_hash_str_str_map.go b/container/gmap/gmap_hash_str_str_map.go index 3a0900d7b..1ffb2b527 100644 --- a/container/gmap/gmap_hash_str_str_map.go +++ b/container/gmap/gmap_hash_str_str_map.go @@ -8,12 +8,10 @@ package gmap import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/internal/empty" - + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/util/gconv" ) type StrStrMap struct { diff --git a/container/gmap/gmap_list_map.go b/container/gmap/gmap_list_map.go index a0f2f1e30..3ef696dfe 100644 --- a/container/gmap/gmap_list_map.go +++ b/container/gmap/gmap_list_map.go @@ -7,15 +7,12 @@ package gmap import ( - "github.com/gogf/gf/v2/internal/json" - - "github.com/gogf/gf/v2/internal/empty" - - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/util/gconv" ) type ListMap struct { diff --git a/container/gmap/gmap_tree_map.go b/container/gmap/gmap_tree_map.go index f357355ca..c81caa48a 100644 --- a/container/gmap/gmap_tree_map.go +++ b/container/gmap/gmap_tree_map.go @@ -10,7 +10,7 @@ import ( "github.com/gogf/gf/v2/container/gtree" ) -// Map based on red-black tree, alias of RedBlackTree. +// TreeMap based on red-black tree, alias of RedBlackTree. type TreeMap = gtree.RedBlackTree // NewTreeMap instantiates a tree map with the custom comparator. diff --git a/container/gmap/gmap_z_basic_test.go b/container/gmap/gmap_z_basic_test.go index df3f6788b..55182170f 100644 --- a/container/gmap/gmap_z_basic_test.go +++ b/container/gmap/gmap_z_basic_test.go @@ -7,11 +7,11 @@ package gmap_test import ( - "github.com/gogf/gf/v2/util/gutil" "testing" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gutil" ) func getValue() interface{} { @@ -163,15 +163,15 @@ func Test_Map_Lock(t *testing.T) { func Test_Map_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewFrom(map[interface{}]interface{}{1: 1, "key1": "val1"}) m_clone := m.Clone() m.Remove(1) - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN(1, m_clone.Keys()) m_clone.Remove("key1") - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN("key1", m.Keys()) }) } diff --git a/container/gmap/gmap_z_example_any_any_test.go b/container/gmap/gmap_z_example_any_any_test.go index 97fccd448..3a0780e18 100644 --- a/container/gmap/gmap_z_example_any_any_test.go +++ b/container/gmap/gmap_z_example_any_any_test.go @@ -8,9 +8,9 @@ package gmap_test import ( "fmt" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" ) func ExampleNew() { diff --git a/container/gmap/gmap_z_unit_any_any_test.go b/container/gmap/gmap_z_unit_any_any_test.go index 0b8ed354c..7de3be37e 100644 --- a/container/gmap/gmap_z_unit_any_any_test.go +++ b/container/gmap/gmap_z_unit_any_any_test.go @@ -7,14 +7,15 @@ package gmap_test import ( + "testing" + "time" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "testing" - "time" ) func Test_AnyAnyMap_Var(t *testing.T) { @@ -148,16 +149,16 @@ func Test_AnyAnyMap_Lock(t *testing.T) { func Test_AnyAnyMap_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewAnyAnyMapFrom(map[interface{}]interface{}{1: 1, 2: "2"}) m_clone := m.Clone() m.Remove(1) - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN(1, m_clone.Keys()) m_clone.Remove(2) - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN(2, m.Keys()) }) } diff --git a/container/gmap/gmap_z_unit_int_any_test.go b/container/gmap/gmap_z_unit_int_any_test.go index fb5e72665..13c65d2b3 100644 --- a/container/gmap/gmap_z_unit_int_any_test.go +++ b/container/gmap/gmap_z_unit_int_any_test.go @@ -7,14 +7,14 @@ package gmap_test import ( - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func getAny() interface{} { @@ -150,16 +150,16 @@ func Test_IntAnyMap_Lock(t *testing.T) { } func Test_IntAnyMap_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewIntAnyMapFrom(map[int]interface{}{1: 1, 2: "2"}) m_clone := m.Clone() m.Remove(1) - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN(1, m_clone.Keys()) m_clone.Remove(2) - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN(2, m.Keys()) }) } diff --git a/container/gmap/gmap_z_unit_int_int_test.go b/container/gmap/gmap_z_unit_int_int_test.go index c2a08bd04..d42c7f86f 100644 --- a/container/gmap/gmap_z_unit_int_int_test.go +++ b/container/gmap/gmap_z_unit_int_int_test.go @@ -7,14 +7,14 @@ package gmap_test import ( - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func getInt() int { @@ -155,16 +155,16 @@ func Test_IntIntMap_Lock(t *testing.T) { func Test_IntIntMap_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewIntIntMapFrom(map[int]int{1: 1, 2: 2}) m_clone := m.Clone() m.Remove(1) - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN(1, m_clone.Keys()) m_clone.Remove(2) - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN(2, m.Keys()) }) } diff --git a/container/gmap/gmap_z_unit_int_str_test.go b/container/gmap/gmap_z_unit_int_str_test.go index 0d2cddbe1..046e2f466 100644 --- a/container/gmap/gmap_z_unit_int_str_test.go +++ b/container/gmap/gmap_z_unit_int_str_test.go @@ -7,14 +7,14 @@ package gmap_test import ( - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func getStr() string { @@ -76,8 +76,8 @@ func Test_IntStrMap_Basic(t *testing.T) { t.AssertIN("a", m.Values()) t.AssertIN("c", m.Values()) - //反转之后不成为以下 map,flip 操作只是翻转原 map - //t.Assert(m.Map(), map[string]int{"a": 1, "c": 3}) + // 反转之后不成为以下 map,flip 操作只是翻转原 map + // t.Assert(m.Map(), map[string]int{"a": 1, "c": 3}) m_f := gmap.NewIntStrMap() m_f.Set(1, "2") m_f.Flip() @@ -155,16 +155,16 @@ func Test_IntStrMap_Lock(t *testing.T) { func Test_IntStrMap_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewIntStrMapFrom(map[int]string{1: "a", 2: "b", 3: "c"}) m_clone := m.Clone() m.Remove(1) - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN(1, m_clone.Keys()) m_clone.Remove(2) - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN(2, m.Keys()) }) } diff --git a/container/gmap/gmap_z_unit_list_map_test.go b/container/gmap/gmap_z_unit_list_map_test.go index a0dc8c7f2..433dd48d0 100644 --- a/container/gmap/gmap_z_unit_list_map_test.go +++ b/container/gmap/gmap_z_unit_list_map_test.go @@ -7,14 +7,14 @@ package gmap_test import ( - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_ListMap_Var(t *testing.T) { @@ -133,15 +133,15 @@ func Test_ListMap_Iterator(t *testing.T) { func Test_ListMap_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewListMapFrom(map[interface{}]interface{}{1: 1, "key1": "val1"}) m_clone := m.Clone() m.Remove(1) - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN(1, m_clone.Keys()) m_clone.Remove("key1") - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN("key1", m.Keys()) }) } diff --git a/container/gmap/gmap_z_unit_str_any_test.go b/container/gmap/gmap_z_unit_str_any_test.go index 0fefa09e0..3dd044478 100644 --- a/container/gmap/gmap_z_unit_str_any_test.go +++ b/container/gmap/gmap_z_unit_str_any_test.go @@ -7,14 +7,14 @@ package gmap_test import ( - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_StrAnyMap_Var(t *testing.T) { @@ -148,16 +148,16 @@ func Test_StrAnyMap_Lock(t *testing.T) { } func Test_StrAnyMap_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewStrAnyMapFrom(map[string]interface{}{"a": 1, "b": "2"}) m_clone := m.Clone() m.Remove("a") - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN("a", m_clone.Keys()) m_clone.Remove("b") - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN("b", m.Keys()) }) } diff --git a/container/gmap/gmap_z_unit_str_int_test.go b/container/gmap/gmap_z_unit_str_int_test.go index 30cc8e470..431e4fa13 100644 --- a/container/gmap/gmap_z_unit_str_int_test.go +++ b/container/gmap/gmap_z_unit_str_int_test.go @@ -7,14 +7,14 @@ package gmap_test import ( - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_StrIntMap_Var(t *testing.T) { @@ -152,16 +152,16 @@ func Test_StrIntMap_Lock(t *testing.T) { func Test_StrIntMap_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewStrIntMapFrom(map[string]int{"a": 1, "b": 2, "c": 3}) m_clone := m.Clone() m.Remove("a") - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN("a", m_clone.Keys()) m_clone.Remove("b") - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN("b", m.Keys()) }) } diff --git a/container/gmap/gmap_z_unit_str_str_test.go b/container/gmap/gmap_z_unit_str_str_test.go index f7f9ef823..2cfe9b4aa 100644 --- a/container/gmap/gmap_z_unit_str_str_test.go +++ b/container/gmap/gmap_z_unit_str_str_test.go @@ -7,14 +7,14 @@ package gmap_test import ( - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_StrStrMap_Var(t *testing.T) { @@ -149,16 +149,16 @@ func Test_StrStrMap_Lock(t *testing.T) { } func Test_StrStrMap_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewStrStrMapFrom(map[string]string{"a": "a", "b": "b", "c": "c"}) m_clone := m.Clone() m.Remove("a") - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN("a", m_clone.Keys()) m_clone.Remove("b") - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN("b", m.Keys()) }) } diff --git a/container/gmap/gmap_z_unit_tree_map_test.go b/container/gmap/gmap_z_unit_tree_map_test.go index f3320f574..b541d127d 100644 --- a/container/gmap/gmap_z_unit_tree_map_test.go +++ b/container/gmap/gmap_z_unit_tree_map_test.go @@ -7,13 +7,13 @@ package gmap_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gutil" ) @@ -152,15 +152,15 @@ func Test_TreeMap_Iterator(t *testing.T) { func Test_TreeMap_Clone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //clone 方法是深克隆 + // clone 方法是深克隆 m := gmap.NewTreeMapFrom(gutil.ComparatorString, map[interface{}]interface{}{1: 1, "key1": "val1"}) m_clone := m.Clone() m.Remove(1) - //修改原 map,clone 后的 map 不影响 + // 修改原 map,clone 后的 map 不影响 t.AssertIN(1, m_clone.Keys()) m_clone.Remove("key1") - //修改clone map,原 map 不影响 + // 修改clone map,原 map 不影响 t.AssertIN("key1", m.Keys()) }) } diff --git a/container/gpool/gpool.go b/container/gpool/gpool.go index 9ee4f80ba..12baececf 100644 --- a/container/gpool/gpool.go +++ b/container/gpool/gpool.go @@ -9,12 +9,12 @@ package gpool import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "time" "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtimer" ) @@ -38,10 +38,10 @@ type poolItem struct { expireAt int64 // Expire timestamp in milliseconds. } -// Creation function for object. +// NewFunc Creation function for object. type NewFunc func() (interface{}, error) -// Destruction function for object. +// ExpireFunc Destruction function for object. type ExpireFunc func(interface{}) // New creates and returns a new object pool. diff --git a/container/gpool/gpool_z_unit_test.go b/container/gpool/gpool_z_unit_test.go index 6ddf91beb..759bc9dce 100644 --- a/container/gpool/gpool_z_unit_test.go +++ b/container/gpool/gpool_z_unit_test.go @@ -11,9 +11,8 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/container/gpool" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" ) @@ -30,29 +29,29 @@ var ef gpool.ExpireFunc = func(i interface{}) { func Test_Gpool(t *testing.T) { gtest.C(t, func(t *gtest.T) { // - //expire = 0 + // expire = 0 p1 := gpool.New(0, nf) p1.Put(1) p1.Put(2) time.Sleep(1 * time.Second) - //test won't be timeout + // test won't be timeout v1, err1 := p1.Get() t.Assert(err1, nil) t.AssertIN(v1, g.Slice{1, 2}) - //test clear + // test clear p1.Clear() t.Assert(p1.Size(), 0) - //test newFunc + // test newFunc v1, err1 = p1.Get() t.Assert(err1, nil) t.Assert(v1, "hello") - //put data again + // put data again p1.Put(3) p1.Put(4) v1, err1 = p1.Get() t.Assert(err1, nil) t.AssertIN(v1, g.Slice{3, 4}) - //test close + // test close p1.Close() v1, err1 = p1.Get() t.Assert(err1, nil) @@ -61,7 +60,7 @@ func Test_Gpool(t *testing.T) { gtest.C(t, func(t *gtest.T) { // - //expire > 0 + // expire > 0 p2 := gpool.New(2*time.Second, nil, ef) for index := 0; index < 10; index++ { p2.Put(index) @@ -70,12 +69,12 @@ func Test_Gpool(t *testing.T) { v2, err2 := p2.Get() t.Assert(err2, nil) t.Assert(v2, 0) - //test timeout expireFunc + // test timeout expireFunc time.Sleep(3 * time.Second) v2, err2 = p2.Get() t.Assert(err2, errors.New("pool is empty")) t.Assert(v2, nil) - //test close expireFunc + // test close expireFunc for index := 0; index < 10; index++ { p2.Put(index) } @@ -90,7 +89,7 @@ func Test_Gpool(t *testing.T) { gtest.C(t, func(t *gtest.T) { // - //expire < 0 + // expire < 0 p3 := gpool.New(-1, nil) v3, err3 := p3.Get() t.Assert(err3, errors.New("pool is empty")) diff --git a/container/gqueue/gqueue_z_example_test.go b/container/gqueue/gqueue_z_example_test.go index d561335ee..f76e5c2e5 100644 --- a/container/gqueue/gqueue_z_example_test.go +++ b/container/gqueue/gqueue_z_example_test.go @@ -9,9 +9,10 @@ package gqueue_test import ( "context" "fmt" + "time" + "github.com/gogf/gf/v2/container/gqueue" "github.com/gogf/gf/v2/os/gtimer" - "time" ) func ExampleNew() { @@ -23,8 +24,6 @@ func ExampleNew() { q.Push(i) } - fmt.Println(q.Len()) - // Close the queue in three seconds. gtimer.SetTimeout(context.Background(), time.Second*3, func(ctx context.Context) { q.Close() @@ -54,7 +53,6 @@ func ExampleNew() { } // Output: - // 10 // 0123456789 } diff --git a/container/gset/gset_any_set.go b/container/gset/gset_any_set.go index 68f3e6d0e..9ab7da1ad 100644 --- a/container/gset/gset_any_set.go +++ b/container/gset/gset_any_set.go @@ -9,6 +9,7 @@ package gset import ( "bytes" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/text/gstr" diff --git a/container/gset/gset_int_set.go b/container/gset/gset_int_set.go index 3c6320a95..efc75bbff 100644 --- a/container/gset/gset_int_set.go +++ b/container/gset/gset_int_set.go @@ -9,6 +9,7 @@ package gset import ( "bytes" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/util/gconv" diff --git a/container/gset/gset_str_set.go b/container/gset/gset_str_set.go index a7f43e773..42c57fd07 100644 --- a/container/gset/gset_str_set.go +++ b/container/gset/gset_str_set.go @@ -9,11 +9,12 @@ package gset import ( "bytes" + "strings" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" - "strings" ) type StrSet struct { diff --git a/container/gset/gset_z_example_any_test.go b/container/gset/gset_z_example_any_test.go index 70a41f582..383ca07ac 100644 --- a/container/gset/gset_z_example_any_test.go +++ b/container/gset/gset_z_example_any_test.go @@ -8,6 +8,7 @@ package gset_test import ( "fmt" + "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/frame/g" ) diff --git a/container/gset/gset_z_example_int_test.go b/container/gset/gset_z_example_int_test.go index d5d2cb411..589b34a21 100644 --- a/container/gset/gset_z_example_int_test.go +++ b/container/gset/gset_z_example_int_test.go @@ -9,6 +9,7 @@ package gset_test import ( "encoding/json" "fmt" + "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/frame/g" ) diff --git a/container/gset/gset_z_example_str_test.go b/container/gset/gset_z_example_str_test.go index 586e55615..b81df2f04 100644 --- a/container/gset/gset_z_example_str_test.go +++ b/container/gset/gset_z_example_str_test.go @@ -9,6 +9,7 @@ package gset_test import ( "encoding/json" "fmt" + "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/frame/g" ) diff --git a/container/gset/gset_z_unit_any_test.go b/container/gset/gset_z_unit_any_test.go index 5dec2a315..be0c56383 100644 --- a/container/gset/gset_z_unit_any_test.go +++ b/container/gset/gset_z_unit_any_test.go @@ -9,18 +9,17 @@ package gset_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "strings" "sync" + "testing" "time" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gset" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" - - "testing" + "github.com/gogf/gf/v2/util/gconv" ) func TestSet_Var(t *testing.T) { diff --git a/container/gset/gset_z_unit_int_test.go b/container/gset/gset_z_unit_int_test.go index c9dda0968..5f7068c75 100644 --- a/container/gset/gset_z_unit_int_test.go +++ b/container/gset/gset_z_unit_int_test.go @@ -9,9 +9,6 @@ package gset_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "strings" "sync" "testing" @@ -19,7 +16,10 @@ import ( "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gset" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func TestIntSet_Var(t *testing.T) { diff --git a/container/gset/gset_z_unit_str_test.go b/container/gset/gset_z_unit_str_test.go index f9042d2d1..eae7cd15a 100644 --- a/container/gset/gset_z_unit_str_test.go +++ b/container/gset/gset_z_unit_str_test.go @@ -9,9 +9,6 @@ package gset_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "strings" "sync" "testing" @@ -19,7 +16,10 @@ import ( "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gset" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func TestStrSet_Var(t *testing.T) { diff --git a/container/gtree/gtree_avltree.go b/container/gtree/gtree_avltree.go index bec0198a3..589353d2d 100644 --- a/container/gtree/gtree_avltree.go +++ b/container/gtree/gtree_avltree.go @@ -8,12 +8,11 @@ package gtree import ( "fmt" - "github.com/gogf/gf/v2/internal/json" - - "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/util/gconv" ) // AVLTree holds elements of the AVL tree. diff --git a/container/gtree/gtree_btree.go b/container/gtree/gtree_btree.go index ffd12c5ca..ec8362639 100644 --- a/container/gtree/gtree_btree.go +++ b/container/gtree/gtree_btree.go @@ -9,13 +9,12 @@ package gtree import ( "bytes" "fmt" - "github.com/gogf/gf/v2/internal/json" "strings" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/util/gconv" ) // BTree holds elements of the B-tree. @@ -587,9 +586,9 @@ func (tree *BTree) isLeaf(node *BTreeNode) bool { return len(node.Children) == 0 } -//func (tree *BTree) isFull(node *BTreeNode) bool { +// func (tree *BTree) isFull(node *BTreeNode) bool { // return len(node.Entries) == tree.maxEntries() -//} +// } func (tree *BTree) shouldSplit(node *BTreeNode) bool { return len(node.Entries) > tree.maxEntries() diff --git a/container/gtree/gtree_redblacktree.go b/container/gtree/gtree_redblacktree.go index 2b917d649..2433648a3 100644 --- a/container/gtree/gtree_redblacktree.go +++ b/container/gtree/gtree_redblacktree.go @@ -8,12 +8,12 @@ package gtree import ( "fmt" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/util/gutil" "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gutil" ) type color bool @@ -119,7 +119,7 @@ func (tree *RedBlackTree) doSet(key interface{}, value interface{}) { compare := tree.getComparator()(key, node.Key) switch { case compare == 0: - //node.Key = key + // node.Key = key node.Value = value return case compare < 0: diff --git a/container/gtype/gtype_bool.go b/container/gtype/gtype_bool.go index 87b36a271..d1b00e3dd 100644 --- a/container/gtype/gtype_bool.go +++ b/container/gtype/gtype_bool.go @@ -8,8 +8,9 @@ package gtype import ( "bytes" - "github.com/gogf/gf/v2/util/gconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Bool is a struct for concurrent-safe operation for type bool. @@ -80,9 +81,8 @@ func (v *Bool) String() string { func (v *Bool) MarshalJSON() ([]byte, error) { if v.Val() { return bytesTrue, nil - } else { - return bytesFalse, nil } + return bytesFalse, nil } // UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal. diff --git a/container/gtype/gtype_byte.go b/container/gtype/gtype_byte.go index 06403ec6e..5a8ffb385 100644 --- a/container/gtype/gtype_byte.go +++ b/container/gtype/gtype_byte.go @@ -7,9 +7,10 @@ package gtype import ( - "github.com/gogf/gf/v2/util/gconv" "strconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Byte is a struct for concurrent-safe operation for type byte. diff --git a/container/gtype/gtype_bytes.go b/container/gtype/gtype_bytes.go index 22d7253b7..8a6834a0c 100644 --- a/container/gtype/gtype_bytes.go +++ b/container/gtype/gtype_bytes.go @@ -9,8 +9,9 @@ package gtype import ( "bytes" "encoding/base64" - "github.com/gogf/gf/v2/util/gconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Bytes is a struct for concurrent-safe operation for type []byte. diff --git a/container/gtype/gtype_float32.go b/container/gtype/gtype_float32.go index 1ec36a574..fc096c8d7 100644 --- a/container/gtype/gtype_float32.go +++ b/container/gtype/gtype_float32.go @@ -7,10 +7,11 @@ package gtype import ( - "github.com/gogf/gf/v2/util/gconv" "math" "strconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Float32 is a struct for concurrent-safe operation for type float32. diff --git a/container/gtype/gtype_float64.go b/container/gtype/gtype_float64.go index 8b6440af4..fd5a2e99e 100644 --- a/container/gtype/gtype_float64.go +++ b/container/gtype/gtype_float64.go @@ -7,10 +7,11 @@ package gtype import ( - "github.com/gogf/gf/v2/util/gconv" "math" "strconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Float64 is a struct for concurrent-safe operation for type float64. diff --git a/container/gtype/gtype_int.go b/container/gtype/gtype_int.go index bee2bf629..9e6dbeaa6 100644 --- a/container/gtype/gtype_int.go +++ b/container/gtype/gtype_int.go @@ -7,9 +7,10 @@ package gtype import ( - "github.com/gogf/gf/v2/util/gconv" "strconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Int is a struct for concurrent-safe operation for type int. diff --git a/container/gtype/gtype_int32.go b/container/gtype/gtype_int32.go index f554832f8..849f3dcd8 100644 --- a/container/gtype/gtype_int32.go +++ b/container/gtype/gtype_int32.go @@ -7,9 +7,10 @@ package gtype import ( - "github.com/gogf/gf/v2/util/gconv" "strconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Int32 is a struct for concurrent-safe operation for type int32. diff --git a/container/gtype/gtype_int64.go b/container/gtype/gtype_int64.go index dbdbf21da..3bf12afef 100644 --- a/container/gtype/gtype_int64.go +++ b/container/gtype/gtype_int64.go @@ -7,9 +7,10 @@ package gtype import ( - "github.com/gogf/gf/v2/util/gconv" "strconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Int64 is a struct for concurrent-safe operation for type int64. diff --git a/container/gtype/gtype_interface.go b/container/gtype/gtype_interface.go index 23633b4c0..455608dfc 100644 --- a/container/gtype/gtype_interface.go +++ b/container/gtype/gtype_interface.go @@ -7,9 +7,10 @@ package gtype import ( + "sync/atomic" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/util/gconv" - "sync/atomic" ) // Interface is a struct for concurrent-safe operation for type interface{}. diff --git a/container/gtype/gtype_uint.go b/container/gtype/gtype_uint.go index 2bff0da7a..e9dada149 100644 --- a/container/gtype/gtype_uint.go +++ b/container/gtype/gtype_uint.go @@ -7,9 +7,10 @@ package gtype import ( - "github.com/gogf/gf/v2/util/gconv" "strconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Uint is a struct for concurrent-safe operation for type uint. diff --git a/container/gtype/gtype_uint32.go b/container/gtype/gtype_uint32.go index 86bd10b75..1e52377e3 100644 --- a/container/gtype/gtype_uint32.go +++ b/container/gtype/gtype_uint32.go @@ -7,9 +7,10 @@ package gtype import ( - "github.com/gogf/gf/v2/util/gconv" "strconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Uint32 is a struct for concurrent-safe operation for type uint32. diff --git a/container/gtype/gtype_uint64.go b/container/gtype/gtype_uint64.go index 3eebc7268..f7cda75bb 100644 --- a/container/gtype/gtype_uint64.go +++ b/container/gtype/gtype_uint64.go @@ -7,9 +7,10 @@ package gtype import ( - "github.com/gogf/gf/v2/util/gconv" "strconv" "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" ) // Uint64 is a struct for concurrent-safe operation for type uint64. diff --git a/container/gtype/gtype_z_bench_basic_test.go b/container/gtype/gtype_z_bench_basic_test.go index 6ddc96424..26f13bd0a 100644 --- a/container/gtype/gtype_z_bench_basic_test.go +++ b/container/gtype/gtype_z_bench_basic_test.go @@ -9,11 +9,11 @@ package gtype_test import ( - "github.com/gogf/gf/v2/container/gtype" "strconv" "sync/atomic" "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/encoding/gbinary" ) diff --git a/container/gtype/gtype_z_bench_json_test.go b/container/gtype/gtype_z_bench_json_test.go index f434987c3..42cd4dc5b 100644 --- a/container/gtype/gtype_z_bench_json_test.go +++ b/container/gtype/gtype_z_bench_json_test.go @@ -9,9 +9,10 @@ package gtype_test import ( + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" - "testing" ) var ( diff --git a/container/gtype/gtype_z_unit_bool_test.go b/container/gtype/gtype_z_unit_bool_test.go index fc214c521..47c31c387 100644 --- a/container/gtype/gtype_z_unit_bool_test.go +++ b/container/gtype/gtype_z_unit_bool_test.go @@ -7,12 +7,12 @@ package gtype_test import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_Bool(t *testing.T) { @@ -27,7 +27,7 @@ func Test_Bool(t *testing.T) { t.AssertEQ(iClone1.Set(true), false) t.AssertEQ(iClone1.Val(), true) - //空参测试 + // 空参测试 i2 := gtype.NewBool() t.AssertEQ(i2.Val(), false) }) diff --git a/container/gtype/gtype_z_unit_byte_test.go b/container/gtype/gtype_z_unit_byte_test.go index bbfa8a461..b035ff0a1 100644 --- a/container/gtype/gtype_z_unit_byte_test.go +++ b/container/gtype/gtype_z_unit_byte_test.go @@ -7,13 +7,13 @@ package gtype_test import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "sync" "testing" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_Byte(t *testing.T) { @@ -34,7 +34,7 @@ func Test_Byte(t *testing.T) { wg.Wait() t.AssertEQ(byte(addTimes), i.Val()) - //空参测试 + // 空参测试 i1 := gtype.NewByte() t.AssertEQ(i1.Val(), byte(0)) }) diff --git a/container/gtype/gtype_z_unit_bytes_test.go b/container/gtype/gtype_z_unit_bytes_test.go index 938078817..f6da7ab13 100644 --- a/container/gtype/gtype_z_unit_bytes_test.go +++ b/container/gtype/gtype_z_unit_bytes_test.go @@ -7,12 +7,12 @@ package gtype_test import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_Bytes(t *testing.T) { diff --git a/container/gtype/gtype_z_unit_float32_test.go b/container/gtype/gtype_z_unit_float32_test.go index 4a8bddaf9..c0a081a6e 100644 --- a/container/gtype/gtype_z_unit_float32_test.go +++ b/container/gtype/gtype_z_unit_float32_test.go @@ -7,12 +7,13 @@ package gtype_test import ( + "math" + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "math" - "testing" ) func Test_Float32(t *testing.T) { @@ -22,7 +23,7 @@ func Test_Float32(t *testing.T) { t.AssertEQ(iClone.Set(0.1), float32(0)) t.AssertEQ(iClone.Val(), float32(0.1)) - //空参测试 + // 空参测试 i1 := gtype.NewFloat32() t.AssertEQ(i1.Val(), float32(0)) }) diff --git a/container/gtype/gtype_z_unit_float64_test.go b/container/gtype/gtype_z_unit_float64_test.go index 8089ba8f5..b5bf088f8 100644 --- a/container/gtype/gtype_z_unit_float64_test.go +++ b/container/gtype/gtype_z_unit_float64_test.go @@ -7,12 +7,13 @@ package gtype_test import ( + "math" + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "math" - "testing" ) func Test_Float64(t *testing.T) { @@ -21,7 +22,7 @@ func Test_Float64(t *testing.T) { iClone := i.Clone() t.AssertEQ(iClone.Set(0.1), float64(0)) t.AssertEQ(iClone.Val(), float64(0.1)) - //空参测试 + // 空参测试 i1 := gtype.NewFloat64() t.AssertEQ(i1.Val(), float64(0)) }) diff --git a/container/gtype/gtype_z_unit_int32_test.go b/container/gtype/gtype_z_unit_int32_test.go index c1fc9cfb8..3a13c5801 100644 --- a/container/gtype/gtype_z_unit_int32_test.go +++ b/container/gtype/gtype_z_unit_int32_test.go @@ -7,13 +7,14 @@ package gtype_test import ( + "math" + "sync" + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "math" - "sync" - "testing" ) func Test_Int32(t *testing.T) { @@ -34,7 +35,7 @@ func Test_Int32(t *testing.T) { wg.Wait() t.AssertEQ(int32(addTimes), i.Val()) - //空参测试 + // 空参测试 i1 := gtype.NewInt32() t.AssertEQ(i1.Val(), int32(0)) }) diff --git a/container/gtype/gtype_z_unit_int64_test.go b/container/gtype/gtype_z_unit_int64_test.go index e1da0f139..1c3966b5d 100644 --- a/container/gtype/gtype_z_unit_int64_test.go +++ b/container/gtype/gtype_z_unit_int64_test.go @@ -7,13 +7,14 @@ package gtype_test import ( + "math" + "sync" + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "math" - "sync" - "testing" ) func Test_Int64(t *testing.T) { @@ -34,7 +35,7 @@ func Test_Int64(t *testing.T) { wg.Wait() t.AssertEQ(int64(addTimes), i.Val()) - //空参测试 + // 空参测试 i1 := gtype.NewInt64() t.AssertEQ(i1.Val(), int64(0)) }) diff --git a/container/gtype/gtype_z_unit_int_test.go b/container/gtype/gtype_z_unit_int_test.go index 3d0d73fea..30c31d9f0 100644 --- a/container/gtype/gtype_z_unit_int_test.go +++ b/container/gtype/gtype_z_unit_int_test.go @@ -7,12 +7,13 @@ package gtype_test import ( + "sync" + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "sync" - "testing" ) func Test_Int(t *testing.T) { @@ -33,7 +34,7 @@ func Test_Int(t *testing.T) { wg.Wait() t.AssertEQ(addTimes, i.Val()) - //空参测试 + // 空参测试 i1 := gtype.NewInt() t.AssertEQ(i1.Val(), 0) }) diff --git a/container/gtype/gtype_z_unit_interface_test.go b/container/gtype/gtype_z_unit_interface_test.go index 710b6fa2f..c65a92601 100644 --- a/container/gtype/gtype_z_unit_interface_test.go +++ b/container/gtype/gtype_z_unit_interface_test.go @@ -7,11 +7,12 @@ package gtype_test import ( + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "testing" ) func Test_Interface(t *testing.T) { @@ -23,7 +24,7 @@ func Test_Interface(t *testing.T) { t.AssertEQ(iClone.Set(t2), t1) t.AssertEQ(iClone.Val().(Temp), t2) - //空参测试 + // 空参测试 i1 := gtype.New() t.AssertEQ(i1.Val(), nil) }) diff --git a/container/gtype/gtype_z_unit_string_test.go b/container/gtype/gtype_z_unit_string_test.go index 83bdcd968..c43830126 100644 --- a/container/gtype/gtype_z_unit_string_test.go +++ b/container/gtype/gtype_z_unit_string_test.go @@ -7,11 +7,12 @@ package gtype_test import ( + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "testing" ) func Test_String(t *testing.T) { @@ -21,7 +22,7 @@ func Test_String(t *testing.T) { t.AssertEQ(iClone.Set("123"), "abc") t.AssertEQ(iClone.Val(), "123") - //空参测试 + // 空参测试 i1 := gtype.NewString() t.AssertEQ(i1.Val(), "") }) diff --git a/container/gtype/gtype_z_unit_uint32_test.go b/container/gtype/gtype_z_unit_uint32_test.go index 2254358fa..3b0a75005 100644 --- a/container/gtype/gtype_z_unit_uint32_test.go +++ b/container/gtype/gtype_z_unit_uint32_test.go @@ -7,13 +7,14 @@ package gtype_test import ( + "math" + "sync" + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "math" - "sync" - "testing" ) func Test_Uint32(t *testing.T) { @@ -34,7 +35,7 @@ func Test_Uint32(t *testing.T) { wg.Wait() t.AssertEQ(uint32(addTimes), i.Val()) - //空参测试 + // 空参测试 i1 := gtype.NewUint32() t.AssertEQ(i1.Val(), uint32(0)) }) diff --git a/container/gtype/gtype_z_unit_uint64_test.go b/container/gtype/gtype_z_unit_uint64_test.go index 5435cc30e..f2285aa3d 100644 --- a/container/gtype/gtype_z_unit_uint64_test.go +++ b/container/gtype/gtype_z_unit_uint64_test.go @@ -7,14 +7,14 @@ package gtype_test import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "math" "sync" "testing" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) type Temp struct { @@ -40,7 +40,7 @@ func Test_Uint64(t *testing.T) { wg.Wait() t.AssertEQ(uint64(addTimes), i.Val()) - //空参测试 + // 空参测试 i1 := gtype.NewUint64() t.AssertEQ(i1.Val(), uint64(0)) }) diff --git a/container/gtype/gtype_z_unit_uint_test.go b/container/gtype/gtype_z_unit_uint_test.go index 34e798e2b..4521e6d6f 100644 --- a/container/gtype/gtype_z_unit_uint_test.go +++ b/container/gtype/gtype_z_unit_uint_test.go @@ -7,12 +7,13 @@ package gtype_test import ( + "sync" + "testing" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "sync" - "testing" ) func Test_Uint(t *testing.T) { @@ -33,7 +34,7 @@ func Test_Uint(t *testing.T) { wg.Wait() t.AssertEQ(uint(addTimes), i.Val()) - //空参测试 + // 空参测试 i1 := gtype.NewUint() t.AssertEQ(i1.Val(), uint(0)) }) diff --git a/container/gvar/gvar.go b/container/gvar/gvar.go index a5412d464..745919fb9 100644 --- a/container/gvar/gvar.go +++ b/container/gvar/gvar.go @@ -8,10 +8,10 @@ package gvar import ( - "github.com/gogf/gf/v2/internal/json" "time" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/container/gvar/gvar_z_unit_basic_test.go b/container/gvar/gvar_z_unit_basic_test.go index ab8845e75..92c2fbd20 100644 --- a/container/gvar/gvar_z_unit_basic_test.go +++ b/container/gvar/gvar_z_unit_basic_test.go @@ -9,12 +9,12 @@ package gvar_test import ( "bytes" "encoding/binary" - "github.com/gogf/gf/v2/util/gconv" "testing" "time" "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_Set(t *testing.T) { diff --git a/container/gvar/gvar_z_unit_is_test.go b/container/gvar/gvar_z_unit_is_test.go index 28d3168bc..c1b9daae7 100644 --- a/container/gvar/gvar_z_unit_is_test.go +++ b/container/gvar/gvar_z_unit_is_test.go @@ -7,9 +7,10 @@ package gvar_test import ( + "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func TestVar_IsNil(t *testing.T) { diff --git a/container/gvar/gvar_z_unit_json_test.go b/container/gvar/gvar_z_unit_json_test.go index e52abe090..d5df2f8ef 100644 --- a/container/gvar/gvar_z_unit_json_test.go +++ b/container/gvar/gvar_z_unit_json_test.go @@ -7,11 +7,12 @@ package gvar_test import ( + "math" + "testing" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" - "math" - "testing" ) func TestVar_Json(t *testing.T) { diff --git a/container/gvar/gvar_z_unit_list_test.go b/container/gvar/gvar_z_unit_list_test.go index 9e024bd43..ecb648e96 100644 --- a/container/gvar/gvar_z_unit_list_test.go +++ b/container/gvar/gvar_z_unit_list_test.go @@ -7,10 +7,11 @@ package gvar_test import ( + "testing" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func TestVar_ListItemValues_Map(t *testing.T) { diff --git a/container/gvar/gvar_z_unit_map_test.go b/container/gvar/gvar_z_unit_map_test.go index 0498bc008..30eab6f66 100644 --- a/container/gvar/gvar_z_unit_map_test.go +++ b/container/gvar/gvar_z_unit_map_test.go @@ -7,10 +7,11 @@ package gvar_test import ( + "testing" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func TestVar_Map(t *testing.T) { diff --git a/container/gvar/gvar_z_unit_slice_test.go b/container/gvar/gvar_z_unit_slice_test.go index 66a319786..874bdfd38 100644 --- a/container/gvar/gvar_z_unit_slice_test.go +++ b/container/gvar/gvar_z_unit_slice_test.go @@ -7,9 +7,10 @@ package gvar_test import ( + "testing" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func TestVar_Ints(t *testing.T) { diff --git a/container/gvar/gvar_z_unit_struct_test.go b/container/gvar/gvar_z_unit_struct_test.go index 1102c4e05..f397acadb 100644 --- a/container/gvar/gvar_z_unit_struct_test.go +++ b/container/gvar/gvar_z_unit_struct_test.go @@ -7,11 +7,12 @@ package gvar_test import ( + "testing" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "testing" ) func TestVar_Struct(t *testing.T) { diff --git a/crypto/gaes/gaes.go b/crypto/gaes/gaes.go index 21a04dcd4..cc86966ae 100644 --- a/crypto/gaes/gaes.go +++ b/crypto/gaes/gaes.go @@ -11,6 +11,7 @@ import ( "bytes" "crypto/aes" "crypto/cipher" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" ) diff --git a/crypto/gaes/gaes_test.go b/crypto/gaes/gaes_test.go index d930fddb4..75ca55b3c 100644 --- a/crypto/gaes/gaes_test.go +++ b/crypto/gaes/gaes_test.go @@ -11,9 +11,8 @@ package gaes_test import ( "testing" - "github.com/gogf/gf/v2/encoding/gbase64" - "github.com/gogf/gf/v2/crypto/gaes" + "github.com/gogf/gf/v2/encoding/gbase64" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/crypto/gdes/gdes.go b/crypto/gdes/gdes.go index e8d7676c7..684cb9b8e 100644 --- a/crypto/gdes/gdes.go +++ b/crypto/gdes/gdes.go @@ -11,6 +11,7 @@ import ( "bytes" "crypto/cipher" "crypto/des" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" ) diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index 64ec50b23..c67129f8a 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -10,20 +10,17 @@ package gdb import ( "context" "database/sql" - "github.com/gogf/gf/v2/errors/gcode" "time" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/os/gcmd" - - "github.com/gogf/gf/v2/container/gvar" - "github.com/gogf/gf/v2/internal/intlog" - - "github.com/gogf/gf/v2/os/glog" - "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gcache" + "github.com/gogf/gf/v2/os/gcmd" + "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/util/grand" ) @@ -455,7 +452,7 @@ func getConfigNodeByWeight(cg ConfigGroup) *ConfigNode { max := 0 for i := 0; i < len(cg); i++ { max = min + cg[i].Weight*100 - //fmt.Printf("r: %d, min: %d, max: %d\n", r, min, max) + // fmt.Printf("r: %d, min: %d, max: %d\n", r, min, max) if r >= min && r < max { return &cg[i] } else { diff --git a/database/gdb/gdb_core.go b/database/gdb/gdb_core.go index 88b8d55a1..09c84ef75 100644 --- a/database/gdb/gdb_core.go +++ b/database/gdb/gdb_core.go @@ -11,17 +11,16 @@ import ( "context" "database/sql" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/internal/intlog" "reflect" "strings" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/utils" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/database/gdb/gdb_core_config.go b/database/gdb/gdb_core_config.go index e4a4d2e27..c08e5bb4a 100644 --- a/database/gdb/gdb_core_config.go +++ b/database/gdb/gdb_core_config.go @@ -8,11 +8,11 @@ package gdb import ( "fmt" - "github.com/gogf/gf/v2/os/glog" "sync" "time" "github.com/gogf/gf/v2/os/gcache" + "github.com/gogf/gf/v2/os/glog" ) // Config is the configuration management object. diff --git a/database/gdb/gdb_core_structure.go b/database/gdb/gdb_core_structure.go index 6df0cd5a6..5cee01ce0 100644 --- a/database/gdb/gdb_core_structure.go +++ b/database/gdb/gdb_core_structure.go @@ -10,16 +10,12 @@ import ( "strings" "time" - "github.com/gogf/gf/v2/util/gutil" - - "github.com/gogf/gf/v2/text/gstr" - - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/encoding/gbinary" - + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gutil" ) // convertFieldValueToLocalValue automatically checks and converts field value from database type diff --git a/database/gdb/gdb_core_tracing.go b/database/gdb/gdb_core_tracing.go index 0cd86a973..004c37b5d 100644 --- a/database/gdb/gdb_core_tracing.go +++ b/database/gdb/gdb_core_tracing.go @@ -10,6 +10,7 @@ package gdb import ( "context" "fmt" + "github.com/gogf/gf/v2" "github.com/gogf/gf/v2/net/gtrace" "go.opentelemetry.io/otel" diff --git a/database/gdb/gdb_core_transaction.go b/database/gdb/gdb_core_transaction.go index d0c5cf613..3f3d3199c 100644 --- a/database/gdb/gdb_core_transaction.go +++ b/database/gdb/gdb_core_transaction.go @@ -9,17 +9,16 @@ package gdb import ( "context" "database/sql" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/utils" "reflect" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/guid" - - "github.com/gogf/gf/v2/text/gregex" ) // TX is the struct for transaction management. diff --git a/database/gdb/gdb_core_underlying.go b/database/gdb/gdb_core_underlying.go index 218e7e477..a6edac505 100644 --- a/database/gdb/gdb_core_underlying.go +++ b/database/gdb/gdb_core_underlying.go @@ -10,9 +10,9 @@ package gdb import ( "context" "database/sql" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/os/gtime" ) diff --git a/database/gdb/gdb_driver_mssql.go b/database/gdb/gdb_driver_mssql.go index a5e8894e9..d55ac4af4 100644 --- a/database/gdb/gdb_driver_mssql.go +++ b/database/gdb/gdb_driver_mssql.go @@ -15,16 +15,14 @@ import ( "context" "database/sql" "fmt" - "github.com/gogf/gf/v2/errors/gcode" "strconv" "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" ) // DriverMssql is the driver for SQL server database. diff --git a/database/gdb/gdb_driver_mysql.go b/database/gdb/gdb_driver_mysql.go index fc6331fb8..4d3d8cf35 100644 --- a/database/gdb/gdb_driver_mysql.go +++ b/database/gdb/gdb_driver_mysql.go @@ -10,14 +10,14 @@ import ( "context" "database/sql" "fmt" + "net/url" + + _ "github.com/go-sql-driver/mysql" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" - "net/url" - - _ "github.com/go-sql-driver/mysql" ) // DriverMysql is the driver for mysql database. diff --git a/database/gdb/gdb_driver_oracle.go b/database/gdb/gdb_driver_oracle.go index f5b1bb40f..44f8225b6 100644 --- a/database/gdb/gdb_driver_oracle.go +++ b/database/gdb/gdb_driver_oracle.go @@ -15,12 +15,12 @@ import ( "context" "database/sql" "fmt" - "github.com/gogf/gf/v2/errors/gcode" "reflect" "strconv" "strings" "time" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/text/gregex" @@ -98,7 +98,7 @@ func (d *DriverOracle) DoCommit(ctx context.Context, link Link, sql string, args if reflect.TypeOf(v).Kind() == reflect.String { valueStr := gconv.String(v) if gregex.IsMatchString(`^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$`, valueStr) { - //args[i] = fmt.Sprintf(`TO_DATE('%s','yyyy-MM-dd HH:MI:SS')`, valueStr) + // args[i] = fmt.Sprintf(`TO_DATE('%s','yyyy-MM-dd HH:MI:SS')`, valueStr) args[i], _ = time.ParseInLocation("2006-01-02 15:04:05", valueStr, time.Local) } } diff --git a/database/gdb/gdb_driver_pgsql.go b/database/gdb/gdb_driver_pgsql.go index c8b7f0065..ab1e9801e 100644 --- a/database/gdb/gdb_driver_pgsql.go +++ b/database/gdb/gdb_driver_pgsql.go @@ -15,14 +15,13 @@ import ( "context" "database/sql" "fmt" - "github.com/gogf/gf/v2/errors/gcode" "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" ) // DriverPgsql is the driver for postgresql database. diff --git a/database/gdb/gdb_driver_sqlite.go b/database/gdb/gdb_driver_sqlite.go index 69b418ae9..15851f7f7 100644 --- a/database/gdb/gdb_driver_sqlite.go +++ b/database/gdb/gdb_driver_sqlite.go @@ -14,9 +14,9 @@ import ( "context" "database/sql" "fmt" - "github.com/gogf/gf/v2/errors/gcode" "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gfile" diff --git a/database/gdb/gdb_func.go b/database/gdb/gdb_func.go index d2360309b..d70ac3379 100644 --- a/database/gdb/gdb_func.go +++ b/database/gdb/gdb_func.go @@ -10,25 +10,23 @@ import ( "bytes" "database/sql" "fmt" - "github.com/gogf/gf/v2/errors/gcode" "reflect" "regexp" "strings" "time" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/structs" "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gmeta" - "github.com/gogf/gf/v2/util/gutil" - - "github.com/gogf/gf/v2/internal/structs" - "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gmeta" + "github.com/gogf/gf/v2/util/gutil" ) // iString is the type assert api for String. @@ -72,6 +70,11 @@ var ( structTagPriority = append([]string{OrmTagForStruct}, gconv.StructTagPriority...) ) +// isForDaoModel checks and returns whether given type is for dao model. +func isForDaoModel(t reflect.Type) bool { + return gstr.HasSuffix(t.String(), modelForDaoSuffix) +} + // getTableNameFromOrmTag retrieves and returns the table name from struct object. func getTableNameFromOrmTag(object interface{}) string { var tableName string @@ -416,7 +419,7 @@ func formatWhere(db DB, in formatWhereInput) (newWhere string, newArgs []interfa case reflect.Struct: // If the `where` parameter is defined like `xxxForDao`, it then adds `OmitNil` option for this condition, // which will filter all nil parameters in `where`. - if gstr.HasSuffix(reflect.TypeOf(in.Where).String(), modelForDaoSuffix) { + if isForDaoModel(reflect.TypeOf(in.Where)) { in.OmitNil = true } // If `where` struct implements iIterator interface, diff --git a/database/gdb/gdb_model.go b/database/gdb/gdb_model.go index 579130e12..723773a1f 100644 --- a/database/gdb/gdb_model.go +++ b/database/gdb/gdb_model.go @@ -9,10 +9,10 @@ package gdb import ( "context" "fmt" - "github.com/gogf/gf/v2/text/gregex" - "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" ) // Model is core struct implementing the DAO for ORM. diff --git a/database/gdb/gdb_model_cache.go b/database/gdb/gdb_model_cache.go index d5637518e..d18db684f 100644 --- a/database/gdb/gdb_model_cache.go +++ b/database/gdb/gdb_model_cache.go @@ -7,8 +7,9 @@ package gdb import ( - "github.com/gogf/gf/v2/internal/intlog" "time" + + "github.com/gogf/gf/v2/internal/intlog" ) type CacheOption struct { diff --git a/database/gdb/gdb_model_condition.go b/database/gdb/gdb_model_condition.go index 62204b0f4..3aeb96d94 100644 --- a/database/gdb/gdb_model_condition.go +++ b/database/gdb/gdb_model_condition.go @@ -8,6 +8,7 @@ package gdb import ( "fmt" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/database/gdb/gdb_model_delete.go b/database/gdb/gdb_model_delete.go index 33c396872..334338f6f 100644 --- a/database/gdb/gdb_model_delete.go +++ b/database/gdb/gdb_model_delete.go @@ -9,8 +9,8 @@ package gdb import ( "database/sql" "fmt" - "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/text/gstr" diff --git a/database/gdb/gdb_model_fields.go b/database/gdb/gdb_model_fields.go index c650d3503..49dbe1e24 100644 --- a/database/gdb/gdb_model_fields.go +++ b/database/gdb/gdb_model_fields.go @@ -8,6 +8,7 @@ package gdb import ( "fmt" + "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" diff --git a/database/gdb/gdb_model_insert.go b/database/gdb/gdb_model_insert.go index 2549190b3..35e58e9d6 100644 --- a/database/gdb/gdb_model_insert.go +++ b/database/gdb/gdb_model_insert.go @@ -8,12 +8,12 @@ package gdb import ( "database/sql" - "github.com/gogf/gf/v2/container/gset" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/internal/utils" "reflect" + "github.com/gogf/gf/v2/container/gset" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" @@ -74,20 +74,26 @@ func (m *Model) Data(data ...interface{}) *Model { ) switch reflectInfo.OriginKind { case reflect.Slice, reflect.Array: + if reflectInfo.OriginValue.Len() > 0 { + // If the `data` parameter is defined like `xxxForDao`, + // it then adds `OmitNilData` option for this condition, + // which will filter all nil parameters in `data`. + if isForDaoModel(reflectInfo.OriginValue.Index(0).Elem().Type()) { + model = model.OmitNilData() + model.option |= optionOmitNilDataInternal + } + } list := make(List, reflectInfo.OriginValue.Len()) for i := 0; i < reflectInfo.OriginValue.Len(); i++ { list[i] = ConvertDataForTableRecord(reflectInfo.OriginValue.Index(i).Interface()) } model.data = list - case reflect.Map: - model.data = ConvertDataForTableRecord(data[0]) - case reflect.Struct: // If the `data` parameter is defined like `xxxForDao`, // it then adds `OmitNilData` option for this condition, // which will filter all nil parameters in `data`. - if gstr.HasSuffix(reflect.TypeOf(value).String(), modelForDaoSuffix) { + if isForDaoModel(reflect.TypeOf(value)) { model = model.OmitNilData() } if v, ok := data[0].(iInterfaces); ok { @@ -103,6 +109,9 @@ func (m *Model) Data(data ...interface{}) *Model { model.data = ConvertDataForTableRecord(data[0]) } + case reflect.Map: + model.data = ConvertDataForTableRecord(data[0]) + default: model.data = data[0] } diff --git a/database/gdb/gdb_model_option.go b/database/gdb/gdb_model_option.go index 3311f6b25..e3947c627 100644 --- a/database/gdb/gdb_model_option.go +++ b/database/gdb/gdb_model_option.go @@ -7,12 +7,14 @@ package gdb const ( - optionOmitNil = optionOmitNilWhere | optionOmitNilData - optionOmitEmpty = optionOmitEmptyWhere | optionOmitEmptyData - optionOmitEmptyWhere = 1 << iota // 8 - optionOmitEmptyData // 16 - optionOmitNilWhere // 32 - optionOmitNilData // 64 + optionOmitNil = optionOmitNilWhere | optionOmitNilData + optionOmitEmpty = optionOmitEmptyWhere | optionOmitEmptyData + optionOmitNilDataInternal = optionOmitNilData | optionOmitNilDataList // this option is used internally only for ForDao feature. + optionOmitEmptyWhere = 1 << iota // 8 + optionOmitEmptyData // 16 + optionOmitNilWhere // 32 + optionOmitNilData // 64 + optionOmitNilDataList // 128 ) // OmitEmpty sets optionOmitEmpty option for the model, which automatically filers diff --git a/database/gdb/gdb_model_select.go b/database/gdb/gdb_model_select.go index 098f514fb..b342852a0 100644 --- a/database/gdb/gdb_model_select.go +++ b/database/gdb/gdb_model_select.go @@ -8,15 +8,15 @@ package gdb import ( "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/utils" "reflect" "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/database/gdb/gdb_model_time.go b/database/gdb/gdb_model_time.go index c600ea0e7..f54445737 100644 --- a/database/gdb/gdb_model_time.go +++ b/database/gdb/gdb_model_time.go @@ -8,6 +8,7 @@ package gdb import ( "fmt" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" diff --git a/database/gdb/gdb_model_update.go b/database/gdb/gdb_model_update.go index 976912e2d..86d4a5a07 100644 --- a/database/gdb/gdb_model_update.go +++ b/database/gdb/gdb_model_update.go @@ -9,11 +9,11 @@ package gdb import ( "database/sql" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/internal/utils" "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" diff --git a/database/gdb/gdb_model_utility.go b/database/gdb/gdb_model_utility.go index 1d0914e0a..d20241d5a 100644 --- a/database/gdb/gdb_model_utility.go +++ b/database/gdb/gdb_model_utility.go @@ -87,8 +87,14 @@ func (m *Model) filterDataForInsertOrUpdate(data interface{}) (interface{}, erro var err error switch value := data.(type) { case List: + var ( + omitEmpty bool + ) + if m.option&optionOmitNilDataList > 0 { + omitEmpty = true + } for k, item := range value { - value[k], err = m.doMappingAndFilterForInsertOrUpdateDataMap(item, false) + value[k], err = m.doMappingAndFilterForInsertOrUpdateDataMap(item, omitEmpty) if err != nil { return nil, err } diff --git a/database/gdb/gdb_model_with.go b/database/gdb/gdb_model_with.go index e4a7280b8..0e103077e 100644 --- a/database/gdb/gdb_model_with.go +++ b/database/gdb/gdb_model_with.go @@ -9,9 +9,9 @@ package gdb import ( "database/sql" "fmt" - "github.com/gogf/gf/v2/errors/gcode" "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/structs" "github.com/gogf/gf/v2/internal/utils" diff --git a/database/gdb/gdb_statement.go b/database/gdb/gdb_statement.go index 59ed63fc1..3db6dd43a 100644 --- a/database/gdb/gdb_statement.go +++ b/database/gdb/gdb_statement.go @@ -9,8 +9,8 @@ package gdb import ( "context" "database/sql" - "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/os/gtime" ) diff --git a/database/gdb/gdb_type_record.go b/database/gdb/gdb_type_record.go index 2af2eb409..2b14c5375 100644 --- a/database/gdb/gdb_type_record.go +++ b/database/gdb/gdb_type_record.go @@ -8,6 +8,7 @@ package gdb import ( "database/sql" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/internal/empty" diff --git a/database/gdb/gdb_type_result.go b/database/gdb/gdb_type_result.go index 7b86b14e4..4b6306200 100644 --- a/database/gdb/gdb_type_result.go +++ b/database/gdb/gdb_type_result.go @@ -7,10 +7,11 @@ package gdb import ( + "math" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/util/gconv" - "math" ) // IsEmpty checks and returns whether `r` is empty. diff --git a/database/gdb/gdb_type_result_scanlist.go b/database/gdb/gdb_type_result_scanlist.go index 0e76b6c61..8195137a3 100644 --- a/database/gdb/gdb_type_result_scanlist.go +++ b/database/gdb/gdb_type_result_scanlist.go @@ -8,13 +8,14 @@ package gdb import ( "database/sql" + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/structs" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gutil" - "reflect" ) // ScanList converts `r` to struct slice which contains other complex struct attributes. diff --git a/database/gdb/gdb_z_init_test.go b/database/gdb/gdb_z_init_test.go index 9c94207e4..22b537ba3 100644 --- a/database/gdb/gdb_z_init_test.go +++ b/database/gdb/gdb_z_init_test.go @@ -9,11 +9,11 @@ package gdb_test import ( "context" "fmt" + "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcmd" - - "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/database/gdb/gdb_z_mysql_association_scanlist_test.go b/database/gdb/gdb_z_mysql_association_scanlist_test.go index 5016d60a4..a167e0a6d 100644 --- a/database/gdb/gdb_z_mysql_association_scanlist_test.go +++ b/database/gdb/gdb_z_mysql_association_scanlist_test.go @@ -13,10 +13,9 @@ import ( "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_Table_Relation_One(t *testing.T) { @@ -1368,19 +1367,19 @@ CREATE TABLE %s ( }) t.AssertNil(err) // Detail. - //_, err = db.Insert(ctx, tableUserDetail, g.Map{ + // _, err = db.Insert(ctx, tableUserDetail, g.Map{ // "uid": i, // "address": fmt.Sprintf(`address_%d`, i), - //}) - //t.AssertNil(err) + // }) + // t.AssertNil(err) // Scores. - //for j := 1; j <= 5; j++ { + // for j := 1; j <= 5; j++ { // _, err = db.Insert(ctx, tableUserScores, g.Map{ // "uid": i, // "score": j, // }) // t.AssertNil(err) - //} + // } } }) diff --git a/database/gdb/gdb_z_mysql_association_with_test.go b/database/gdb/gdb_z_mysql_association_with_test.go index bae1adb92..d0aeb549b 100644 --- a/database/gdb/gdb_z_mysql_association_with_test.go +++ b/database/gdb/gdb_z_mysql_association_with_test.go @@ -8,13 +8,14 @@ package gdb_test import ( "fmt" + "testing" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gmeta" - "testing" ) /* @@ -1675,7 +1676,7 @@ func Test_Table_Relation_With_MultipleDepends1(t *testing.T) { gtest.C(t, func(t *gtest.T) { var tableA *TableA err := db.Model("table_a").WithAll().Scan(&tableA) - //g.Dump(tableA) + // g.Dump(tableA) t.AssertNil(err) t.AssertNE(tableA, nil) t.Assert(tableA.Id, 1) @@ -1691,7 +1692,7 @@ func Test_Table_Relation_With_MultipleDepends1(t *testing.T) { gtest.C(t, func(t *gtest.T) { var tableA []*TableA err := db.Model("table_a").WithAll().OrderAsc("id").Scan(&tableA) - //g.Dump(tableA) + // g.Dump(tableA) t.AssertNil(err) t.Assert(len(tableA), 2) t.AssertNE(tableA[0].TableB, nil) @@ -1747,7 +1748,7 @@ func Test_Table_Relation_With_MultipleDepends2(t *testing.T) { gtest.C(t, func(t *gtest.T) { var tableA *TableA err := db.Model("table_a").WithAll().Scan(&tableA) - //g.Dump(tableA) + // g.Dump(tableA) t.AssertNil(err) t.AssertNE(tableA, nil) t.Assert(tableA.Id, 1) @@ -1770,7 +1771,7 @@ func Test_Table_Relation_With_MultipleDepends2(t *testing.T) { gtest.C(t, func(t *gtest.T) { var tableA []*TableA err := db.Model("table_a").WithAll().OrderAsc("id").Scan(&tableA) - //g.Dump(tableA) + // g.Dump(tableA) t.AssertNil(err) t.Assert(len(tableA), 2) @@ -1834,7 +1835,7 @@ func Test_Table_Relation_With_MultipleDepends_Embedded(t *testing.T) { gtest.C(t, func(t *gtest.T) { var tableA *TableA err := db.Model("table_a").WithAll().Scan(&tableA) - //g.Dump(tableA) + // g.Dump(tableA) t.AssertNil(err) t.AssertNE(tableA, nil) t.Assert(tableA.Id, 1) @@ -1850,7 +1851,7 @@ func Test_Table_Relation_With_MultipleDepends_Embedded(t *testing.T) { gtest.C(t, func(t *gtest.T) { var tableA []*TableA err := db.Model("table_a").WithAll().OrderAsc("id").Scan(&tableA) - //g.Dump(tableA) + // g.Dump(tableA) t.AssertNil(err) t.Assert(len(tableA), 2) t.AssertNE(tableA[0].TableB, nil) @@ -1962,7 +1963,7 @@ PRIMARY KEY (id) db.SetDebug(true) defer db.SetDebug(false) - //gtest.C(t, func(t *gtest.T) { + // gtest.C(t, func(t *gtest.T) { // var user *User // err := db.Model(tableUser).WithAll().Where("id", 3).Scan(&user) // t.AssertNil(err) @@ -1975,7 +1976,7 @@ PRIMARY KEY (id) // t.Assert(user.UserScores[0].Score, 1) // t.Assert(user.UserScores[4].UserID, 3) // t.Assert(user.UserScores[4].Score, 5) - //}) + // }) gtest.C(t, func(t *gtest.T) { var user User err := db.Model(tableUser).WithAll().Where("id", 4).Scan(&user) diff --git a/database/gdb/gdb_z_mysql_basic_test.go b/database/gdb/gdb_z_mysql_basic_test.go index 85fff7d61..61d116752 100644 --- a/database/gdb/gdb_z_mysql_basic_test.go +++ b/database/gdb/gdb_z_mysql_basic_test.go @@ -7,10 +7,11 @@ package gdb_test import ( + "testing" + "github.com/go-sql-driver/mysql" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func Test_Instance(t *testing.T) { diff --git a/database/gdb/gdb_z_mysql_internal_test.go b/database/gdb/gdb_z_mysql_internal_test.go index ad90d3b54..2d9228a03 100644 --- a/database/gdb/gdb_z_mysql_internal_test.go +++ b/database/gdb/gdb_z_mysql_internal_test.go @@ -9,11 +9,12 @@ package gdb import ( "context" "fmt" + "testing" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/os/gcmd" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" - "testing" ) const ( @@ -497,7 +498,7 @@ func Test_ScanList_NoRecreate_SliceAttribute_Ptr(t *testing.T) { }, } err = r2.ScanList(&s, "Many", "One", "pid:Id") - //fmt.Printf("%+v", err) + // fmt.Printf("%+v", err) t.AssertNil(err) t.Assert(len(s), 2) t.Assert(s[0].One.Name, "john") @@ -525,7 +526,7 @@ func Test_ScanList_NoRecreate_SliceAttribute_Ptr(t *testing.T) { }, } err = r3.ScanList(&s, "Many", "One", "pid:Id") - //fmt.Printf("%+v", err) + // fmt.Printf("%+v", err) t.AssertNil(err) t.Assert(len(s), 2) t.Assert(s[0].One.Name, "john") @@ -601,7 +602,7 @@ func Test_ScanList_NoRecreate_SliceAttribute_Struct(t *testing.T) { }, } err = r2.ScanList(&s, "Many", "One", "pid:Id") - //fmt.Printf("%+v", err) + // fmt.Printf("%+v", err) t.AssertNil(err) t.Assert(len(s), 2) t.Assert(s[0].One.Name, "john") @@ -629,7 +630,7 @@ func Test_ScanList_NoRecreate_SliceAttribute_Struct(t *testing.T) { }, } err = r3.ScanList(&s, "Many", "One", "pid:Id") - //fmt.Printf("%+v", err) + // fmt.Printf("%+v", err) t.AssertNil(err) t.Assert(len(s), 2) t.Assert(s[0].One.Name, "john") diff --git a/database/gdb/gdb_z_mysql_method_test.go b/database/gdb/gdb_z_mysql_method_test.go index ae8f7a383..49795cb8b 100644 --- a/database/gdb/gdb_z_mysql_method_test.go +++ b/database/gdb/gdb_z_mysql_method_test.go @@ -9,18 +9,17 @@ package gdb_test import ( "context" "fmt" - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/text/gstr" "testing" "time" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/encoding/gxml" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" ) func Test_DB_Ping(t *testing.T) { @@ -274,7 +273,7 @@ func Test_DB_Upadte_KeyFieldNameMapping(t *testing.T) { } // This is no longer used as the filter feature is automatically enabled from GoFrame v1.16.0. -//func Test_DB_Insert_KeyFieldNameMapping_Error(t *testing.T) { +// func Test_DB_Insert_KeyFieldNameMapping_Error(t *testing.T) { // table := createTable() // defer dropTable(table) // @@ -297,7 +296,7 @@ func Test_DB_Upadte_KeyFieldNameMapping(t *testing.T) { // _, err := db.Insert(ctx, table, data) // t.AssertNE(err, nil) // }) -//} +// } func Test_DB_InsertIgnore(t *testing.T) { table := createInitTable() @@ -820,7 +819,7 @@ func Test_DB_ToJson(t *testing.T) { gtest.Fatal(err) } - //ToJson + // ToJson resultJson, err := gjson.LoadContent(result.Json()) if err != nil { gtest.Fatal(err) diff --git a/database/gdb/gdb_z_mysql_model_basic_test.go b/database/gdb/gdb_z_mysql_model_basic_test.go index 2d055a3fc..86b81d756 100644 --- a/database/gdb/gdb_z_mysql_model_basic_test.go +++ b/database/gdb/gdb_z_mysql_model_basic_test.go @@ -11,23 +11,21 @@ import ( "context" "database/sql" "fmt" - "github.com/gogf/gf/v2/encoding/gjson" - "github.com/gogf/gf/v2/text/gstr" "os" "testing" "time" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/util/gutil" - "github.com/gogf/gf/v2/database/gdb" - + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gutil" ) func Test_Model_Insert(t *testing.T) { @@ -706,16 +704,16 @@ func Test_Model_Count(t *testing.T) { t.AssertNil(err) t.Assert(count, TableSize) }) - //gtest.C(t, func(t *gtest.T) { + // gtest.C(t, func(t *gtest.T) { // count, err := db.Model(table).Fields("id myid").Where("id>8").Count() // t.AssertNil(err) // t.Assert(count, 2) - //}) - //gtest.C(t, func(t *gtest.T) { + // }) + // gtest.C(t, func(t *gtest.T) { // count, err := db.Model(table).As("u1").LeftJoin(table, "u2", "u2.id=u1.id").Fields("u2.id u2id").Where("u1.id>8").Count() // t.AssertNil(err) // t.Assert(count, 2) - //}) + // }) } func Test_Model_Select(t *testing.T) { @@ -954,8 +952,8 @@ func Test_Model_StructsWithOrmTag(t *testing.T) { ) }) - //db.SetDebug(true) - //defer db.SetDebug(false) + // db.SetDebug(true) + // defer db.SetDebug(false) gtest.C(t, func(t *gtest.T) { type A struct { Passport string @@ -1302,7 +1300,7 @@ func Test_Model_Where(t *testing.T) { // complicated where 1 gtest.C(t, func(t *gtest.T) { - //db.SetDebug(true) + // db.SetDebug(true) conditions := g.Map{ "nickname like ?": "%name%", "id between ? and ?": g.Slice{1, 3}, @@ -1317,7 +1315,7 @@ func Test_Model_Where(t *testing.T) { }) // complicated where 2 gtest.C(t, func(t *gtest.T) { - //db.SetDebug(true) + // db.SetDebug(true) conditions := g.Map{ "nickname like ?": "%name%", "id between ? and ?": g.Slice{1, 3}, @@ -1390,7 +1388,7 @@ func Test_Model_Where_ISNULL_1(t *testing.T) { defer dropTable(table) gtest.C(t, func(t *gtest.T) { - //db.SetDebug(true) + // db.SetDebug(true) result, err := db.Model(table).Data("nickname", nil).Where("id", 2).Update() t.AssertNil(err) n, _ := result.RowsAffected() @@ -1409,7 +1407,7 @@ func Test_Model_Where_ISNULL_2(t *testing.T) { // complicated one. gtest.C(t, func(t *gtest.T) { - //db.SetDebug(true) + // db.SetDebug(true) conditions := g.Map{ "nickname like ?": "%name%", "id between ? and ?": g.Slice{1, 3}, @@ -1638,7 +1636,7 @@ func Test_Model_WherePri(t *testing.T) { // complicated where 1 gtest.C(t, func(t *gtest.T) { - //db.SetDebug(true) + // db.SetDebug(true) conditions := g.Map{ "nickname like ?": "%name%", "id between ? and ?": g.Slice{1, 3}, @@ -1653,7 +1651,7 @@ func Test_Model_WherePri(t *testing.T) { }) // complicated where 2 gtest.C(t, func(t *gtest.T) { - //db.SetDebug(true) + // db.SetDebug(true) conditions := g.Map{ "nickname like ?": "%name%", "id between ? and ?": g.Slice{1, 3}, @@ -2212,7 +2210,7 @@ func Test_Model_Prefix(t *testing.T) { } func Test_Model_Schema1(t *testing.T) { - //db.SetDebug(true) + // db.SetDebug(true) db.SetSchema(TestSchema1) table := fmt.Sprintf(`%s_%s`, TableName, gtime.TimestampNanoStr()) @@ -2291,7 +2289,7 @@ func Test_Model_Schema1(t *testing.T) { } func Test_Model_Schema2(t *testing.T) { - //db.SetDebug(true) + // db.SetDebug(true) db.SetSchema(TestSchema1) table := fmt.Sprintf(`%s_%s`, TableName, gtime.TimestampNanoStr()) @@ -2956,7 +2954,7 @@ func Test_Model_Issue1002(t *testing.T) { } }) // where + time.Time arguments, +8. - //gtest.C(t, func(t *gtest.T) { + // gtest.C(t, func(t *gtest.T) { // // Change current timezone to +8 zone. // location, err := time.LoadLocation("Asia/Shanghai") // t.AssertNil(err) @@ -2977,7 +2975,7 @@ func Test_Model_Issue1002(t *testing.T) { // t.AssertNil(err) // t.Assert(v.Int(), 1) // } - //}) + // }) } func createTableForTimeZoneTest() string { @@ -3190,7 +3188,7 @@ func Test_Model_WhereOrBetween(t *testing.T) { func Test_Model_WhereOrNotBetween(t *testing.T) { table := createInitTable() defer dropTable(table) - //db.SetDebug(true) + // db.SetDebug(true) gtest.C(t, func(t *gtest.T) { result, err := db.Model(table).WhereOrNotBetween("id", 1, 4).WhereOrNotBetween("id", 3, 5).OrderDesc("id").All() t.AssertNil(err) diff --git a/database/gdb/gdb_z_mysql_model_filter_test.go b/database/gdb/gdb_z_mysql_model_filter_test.go index 5219fd38c..1d5c59ff5 100644 --- a/database/gdb/gdb_z_mysql_model_filter_test.go +++ b/database/gdb/gdb_z_mysql_model_filter_test.go @@ -8,10 +8,11 @@ package gdb_test import ( "fmt" + "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" - "testing" ) // Using filter dose not affect the outside value inside function. @@ -107,7 +108,7 @@ func Test_Model_Embedded_Filter(t *testing.T) { } // This is no longer used as the filter feature is automatically enabled from GoFrame v1.16.0. -//func Test_Model_Insert_KeyFieldNameMapping_Error(t *testing.T) { +// func Test_Model_Insert_KeyFieldNameMapping_Error(t *testing.T) { // table := createTable() // defer dropTable(table) // @@ -130,7 +131,7 @@ func Test_Model_Embedded_Filter(t *testing.T) { // _, err := db.Model(table).Data(data).Insert() // t.AssertNE(err, nil) // }) -//} +// } func Test_Model_Fields_AutoFilterInJoinStatement(t *testing.T) { gtest.C(t, func(t *gtest.T) { diff --git a/database/gdb/gdb_z_mysql_model_for_dao_test.go b/database/gdb/gdb_z_mysql_model_for_dao_test.go index a66f9c7d7..5d4dc7934 100644 --- a/database/gdb/gdb_z_mysql_model_for_dao_test.go +++ b/database/gdb/gdb_z_mysql_model_for_dao_test.go @@ -7,8 +7,10 @@ package gdb_test import ( - "github.com/gogf/gf/v2/test/gtest" "testing" + + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/test/gtest" ) func Test_Model_Insert_Data_ForDao(t *testing.T) { @@ -43,6 +45,53 @@ func Test_Model_Insert_Data_ForDao(t *testing.T) { }) } +func Test_Model_Insert_Data_LIst_ForDao(t *testing.T) { + table := createTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + type UserForDao struct { + Id interface{} + Passport interface{} + Password interface{} + Nickname interface{} + CreateTime interface{} + } + data := g.Slice{ + UserForDao{ + Id: 1, + Passport: "user_1", + Password: "pass_1", + }, + UserForDao{ + Id: 2, + Passport: "user_2", + Password: "pass_2", + }, + } + result, err := db.Model(table).Data(data).Insert() + t.AssertNil(err) + n, _ := result.LastInsertId() + t.Assert(n, 2) + + one, err := db.Model(table).WherePri(1).One() + t.AssertNil(err) + t.Assert(one[`id`], `1`) + t.Assert(one[`passport`], `user_1`) + t.Assert(one[`password`], `pass_1`) + t.Assert(one[`nickname`], ``) + t.Assert(one[`create_time`], ``) + + one, err = db.Model(table).WherePri(2).One() + t.AssertNil(err) + t.Assert(one[`id`], `2`) + t.Assert(one[`passport`], `user_2`) + t.Assert(one[`password`], `pass_2`) + t.Assert(one[`nickname`], ``) + t.Assert(one[`create_time`], ``) + }) +} + func Test_Model_Update_Data_ForDao(t *testing.T) { table := createInitTable() defer dropTable(table) diff --git a/database/gdb/gdb_z_mysql_model_join_test.go b/database/gdb/gdb_z_mysql_model_join_test.go index 5ffb07ae8..6044911f8 100644 --- a/database/gdb/gdb_z_mysql_model_join_test.go +++ b/database/gdb/gdb_z_mysql_model_join_test.go @@ -7,10 +7,11 @@ package gdb_test import ( + "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func Test_Model_LeftJoinOnField(t *testing.T) { diff --git a/database/gdb/gdb_z_mysql_model_struct_test.go b/database/gdb/gdb_z_mysql_model_struct_test.go index a3bf0a543..aa54bcf3e 100644 --- a/database/gdb/gdb_z_mysql_model_struct_test.go +++ b/database/gdb/gdb_z_mysql_model_struct_test.go @@ -8,6 +8,9 @@ package gdb_test import ( "database/sql" + "reflect" + "testing" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" @@ -16,8 +19,6 @@ import ( "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" - "reflect" - "testing" ) func Test_Model_Embedded_Insert(t *testing.T) { @@ -466,7 +467,7 @@ func Test_Scan_AutoFilteringByStructAttributes(t *testing.T) { Id int Passport string } - //db.SetDebug(true) + // db.SetDebug(true) gtest.C(t, func(t *gtest.T) { var user *User err := db.Model(table).OrderAsc("id").Scan(&user) diff --git a/database/gdb/gdb_z_mysql_model_subquery_test.go b/database/gdb/gdb_z_mysql_model_subquery_test.go index 1c2dcb4b0..6eb9d4129 100644 --- a/database/gdb/gdb_z_mysql_model_subquery_test.go +++ b/database/gdb/gdb_z_mysql_model_subquery_test.go @@ -7,9 +7,9 @@ package gdb_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/database/gdb/gdb_z_mysql_model_where_test.go b/database/gdb/gdb_z_mysql_model_where_test.go index 796d23ffc..044083ad7 100644 --- a/database/gdb/gdb_z_mysql_model_where_test.go +++ b/database/gdb/gdb_z_mysql_model_where_test.go @@ -7,10 +7,11 @@ package gdb_test import ( + "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func Test_Model_WherePrefix(t *testing.T) { diff --git a/database/gdb/gdb_z_mysql_raw_type_test.go b/database/gdb/gdb_z_mysql_raw_type_test.go index 9b38adf43..3ce8f556b 100644 --- a/database/gdb/gdb_z_mysql_raw_type_test.go +++ b/database/gdb/gdb_z_mysql_raw_type_test.go @@ -7,10 +7,10 @@ package gdb_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/database/gdb/gdb_z_mysql_time_maintain_test.go b/database/gdb/gdb_z_mysql_time_maintain_test.go index 78c9886f7..8621dc4e9 100644 --- a/database/gdb/gdb_z_mysql_time_maintain_test.go +++ b/database/gdb/gdb_z_mysql_time_maintain_test.go @@ -8,12 +8,11 @@ package gdb_test import ( "fmt" - "github.com/gogf/gf/v2/os/gtime" "testing" "time" "github.com/gogf/gf/v2/frame/g" - + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) @@ -566,7 +565,7 @@ CREATE TABLE %s ( defer dropTable(table2) gtest.C(t, func(t *gtest.T) { - //db.SetDebug(true) + // db.SetDebug(true) dataInsert1 := g.Map{ "id": 1, "name": "name_1", @@ -620,7 +619,7 @@ CREATE TABLE %s ( gtest.Error(err) } defer dropTable(table) - //db.SetDebug(true) + // db.SetDebug(true) // Add datas. gtest.C(t, func(t *gtest.T) { for i := 1; i <= 10; i++ { @@ -663,8 +662,8 @@ CREATE TABLE %s ( } defer dropTable(table) - //db.SetDebug(true) - //defer db.SetDebug(false) + // db.SetDebug(true) + // defer db.SetDebug(false) type Entity struct { Id uint64 `orm:"id,primary" json:"id"` diff --git a/database/gdb/gdb_z_mysql_transaction_test.go b/database/gdb/gdb_z_mysql_transaction_test.go index d9c8d9690..d0da6fd6b 100644 --- a/database/gdb/gdb_z_mysql_transaction_test.go +++ b/database/gdb/gdb_z_mysql_transaction_test.go @@ -9,13 +9,12 @@ package gdb_test import ( "context" "fmt" - "github.com/gogf/gf/v2/os/gctx" "testing" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) @@ -955,8 +954,8 @@ func Test_Transaction_Nested_TX_Transaction_UseDB(t *testing.T) { table := createTable() defer dropTable(table) - //db.SetDebug(true) - //defer db.SetDebug(false) + // db.SetDebug(true) + // defer db.SetDebug(false) gtest.C(t, func(t *gtest.T) { var ( diff --git a/database/gdb/gdb_z_mysql_types_test.go b/database/gdb/gdb_z_mysql_types_test.go index 12126617f..f184dfb3c 100644 --- a/database/gdb/gdb_z_mysql_types_test.go +++ b/database/gdb/gdb_z_mysql_types_test.go @@ -8,11 +8,10 @@ package gdb_test import ( "fmt" - "github.com/gogf/gf/v2/os/gtime" "testing" "github.com/gogf/gf/v2/frame/g" - + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/database/gdb/gdb_z_mysql_union_test.go b/database/gdb/gdb_z_mysql_union_test.go index fc31aa517..2626be62b 100644 --- a/database/gdb/gdb_z_mysql_union_test.go +++ b/database/gdb/gdb_z_mysql_union_test.go @@ -7,9 +7,9 @@ package gdb_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/database/gdb/gdb_z_oracle_internal_test.go b/database/gdb/gdb_z_oracle_internal_test.go index c31084757..1c01aadd7 100644 --- a/database/gdb/gdb_z_oracle_internal_test.go +++ b/database/gdb/gdb_z_oracle_internal_test.go @@ -7,8 +7,9 @@ package gdb import ( - "github.com/gogf/gf/v2/test/gtest" "testing" + + "github.com/gogf/gf/v2/test/gtest" ) func Test_Oracle_parseSql(t *testing.T) { diff --git a/database/gredis/gredis_adapter.go b/database/gredis/gredis_adapter.go index 1d2061211..99531e4be 100644 --- a/database/gredis/gredis_adapter.go +++ b/database/gredis/gredis_adapter.go @@ -8,6 +8,7 @@ package gredis import ( "context" + "github.com/gogf/gf/v2/container/gvar" ) diff --git a/database/gredis/gredis_adapter_goredis.go b/database/gredis/gredis_adapter_goredis.go index 50ed5a92c..4081b7037 100644 --- a/database/gredis/gredis_adapter_goredis.go +++ b/database/gredis/gredis_adapter_goredis.go @@ -8,9 +8,10 @@ package gredis import ( "context" + "time" + "github.com/go-redis/redis/v8" "github.com/gogf/gf/v2/text/gstr" - "time" ) // AdapterGoRedis is an implement of Adapter using go-redis. diff --git a/database/gredis/gredis_adapter_goredis_conn.go b/database/gredis/gredis_adapter_goredis_conn.go index 836eadb9c..36e32223f 100644 --- a/database/gredis/gredis_adapter_goredis_conn.go +++ b/database/gredis/gredis_adapter_goredis_conn.go @@ -8,6 +8,7 @@ package gredis import ( "context" + "github.com/go-redis/redis/v8" "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/text/gstr" diff --git a/database/gredis/gredis_config.go b/database/gredis/gredis_config.go index 6b75e84f4..e3431609e 100644 --- a/database/gredis/gredis_config.go +++ b/database/gredis/gredis_config.go @@ -9,12 +9,12 @@ package gredis import ( "context" "crypto/tls" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" "time" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/database/gredis/gredis_instance.go b/database/gredis/gredis_instance.go index 915099726..2582ac3df 100644 --- a/database/gredis/gredis_instance.go +++ b/database/gredis/gredis_instance.go @@ -8,6 +8,7 @@ package gredis import ( "context" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/internal/intlog" ) diff --git a/database/gredis/gredis_redis.go b/database/gredis/gredis_redis.go index 9d56a9cc3..9ade61f5a 100644 --- a/database/gredis/gredis_redis.go +++ b/database/gredis/gredis_redis.go @@ -8,6 +8,7 @@ package gredis import ( "context" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" diff --git a/database/gredis/gredis_redis_conn.go b/database/gredis/gredis_redis_conn.go index 9a330fba9..78396c737 100644 --- a/database/gredis/gredis_redis_conn.go +++ b/database/gredis/gredis_redis_conn.go @@ -8,11 +8,12 @@ package gredis import ( "context" + "reflect" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/os/gtime" - "reflect" ) // RedisConn is a connection of redis client. diff --git a/database/gredis/gredis_redis_tracing.go b/database/gredis/gredis_redis_tracing.go index 974c82515..b2d41c75b 100644 --- a/database/gredis/gredis_redis_tracing.go +++ b/database/gredis/gredis_redis_tracing.go @@ -9,6 +9,7 @@ package gredis import ( "context" "fmt" + "github.com/gogf/gf/v2" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/net/gtrace" diff --git a/database/gredis/gredis_z_example_test.go b/database/gredis/gredis_z_example_test.go index 4baa5b8f6..d5043a8c4 100644 --- a/database/gredis/gredis_z_example_test.go +++ b/database/gredis/gredis_z_example_test.go @@ -9,6 +9,7 @@ package gredis_test import ( "context" "fmt" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/util/gutil" diff --git a/database/gredis/gredis_z_unit_config_test.go b/database/gredis/gredis_z_unit_config_test.go index e00a3c1a0..7a0995b19 100644 --- a/database/gredis/gredis_z_unit_config_test.go +++ b/database/gredis/gredis_z_unit_config_test.go @@ -7,11 +7,12 @@ package gredis_test import ( + "testing" + "time" + "github.com/gogf/gf/v2/database/gredis" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" - "testing" - "time" ) func Test_ConfigFromMap(t *testing.T) { diff --git a/database/gredis/gredis_z_unit_conn_test.go b/database/gredis/gredis_z_unit_conn_test.go index 28925214d..f3f6b1bd0 100644 --- a/database/gredis/gredis_z_unit_conn_test.go +++ b/database/gredis/gredis_z_unit_conn_test.go @@ -8,9 +8,10 @@ package gredis_test import ( "context" + "testing" + "github.com/gogf/gf/v2/database/gredis" "github.com/gogf/gf/v2/test/gtest" - "testing" ) var ( diff --git a/database/gredis/gredis_z_unit_test.go b/database/gredis/gredis_z_unit_test.go index 4e8cfc493..dfa5daa68 100644 --- a/database/gredis/gredis_z_unit_test.go +++ b/database/gredis/gredis_z_unit_test.go @@ -7,18 +7,17 @@ package gredis_test import ( - "github.com/gogf/gf/v2/container/gvar" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/util/guid" - "github.com/gogf/gf/v2/util/gutil" "testing" "time" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv" - + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/database/gredis" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/guid" + "github.com/gogf/gf/v2/util/gutil" ) var ( diff --git a/debug/gdebug/gdebug_caller.go b/debug/gdebug/gdebug_caller.go index d084b8c58..70bb1a28f 100644 --- a/debug/gdebug/gdebug_caller.go +++ b/debug/gdebug/gdebug_caller.go @@ -8,13 +8,14 @@ package gdebug import ( "fmt" - "github.com/gogf/gf/v2/internal/utils" "os" "os/exec" "path/filepath" "reflect" "runtime" "strings" + + "github.com/gogf/gf/v2/internal/utils" ) const ( diff --git a/debug/gdebug/gdebug_stack.go b/debug/gdebug/gdebug_stack.go index 5bafbcdd9..2a70b542e 100644 --- a/debug/gdebug/gdebug_stack.go +++ b/debug/gdebug/gdebug_stack.go @@ -9,9 +9,10 @@ package gdebug import ( "bytes" "fmt" - "github.com/gogf/gf/v2/internal/utils" "runtime" "strings" + + "github.com/gogf/gf/v2/internal/utils" ) // PrintStack prints to standard error the stack trace returned by runtime.Stack. diff --git a/debug/gdebug/gdebug_version.go b/debug/gdebug/gdebug_version.go index 708a326e3..55fb56393 100644 --- a/debug/gdebug/gdebug_version.go +++ b/debug/gdebug/gdebug_version.go @@ -7,10 +7,11 @@ package gdebug import ( - "github.com/gogf/gf/v2/crypto/gmd5" - "github.com/gogf/gf/v2/encoding/ghash" "io/ioutil" "strconv" + + "github.com/gogf/gf/v2/crypto/gmd5" + "github.com/gogf/gf/v2/encoding/ghash" ) // BinVersion returns the version of current running binary. diff --git a/encoding/gbase64/gbase64.go b/encoding/gbase64/gbase64.go index 6222f4289..6308947f1 100644 --- a/encoding/gbase64/gbase64.go +++ b/encoding/gbase64/gbase64.go @@ -29,7 +29,7 @@ func EncodeToString(src []byte) string { return string(Encode(src)) } -// EncryptFile encodes file content of `path` using BASE64 algorithms. +// EncodeFile encodes file content of `path` using BASE64 algorithms. func EncodeFile(path string) ([]byte, error) { content, err := ioutil.ReadFile(path) if err != nil { @@ -99,7 +99,7 @@ func MustDecodeString(data string) []byte { return result } -// DecodeString decodes string with BASE64 algorithm. +// DecodeToString decodes string with BASE64 algorithm. func DecodeToString(data string) (string, error) { b, err := DecodeString(data) return string(b), err diff --git a/encoding/gbase64/gbase64_test.go b/encoding/gbase64/gbase64_test.go index 90e923628..d77921e63 100644 --- a/encoding/gbase64/gbase64_test.go +++ b/encoding/gbase64/gbase64_test.go @@ -7,9 +7,9 @@ package gbase64_test import ( - "github.com/gogf/gf/v2/debug/gdebug" "testing" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/encoding/gbase64" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/encoding/gbinary/gbinary_bit.go b/encoding/gbinary/gbinary_bit.go index 536fb4030..e382fecea 100644 --- a/encoding/gbinary/gbinary_bit.go +++ b/encoding/gbinary/gbinary_bit.go @@ -8,14 +8,18 @@ package gbinary // NOTE: THIS IS AN EXPERIMENTAL FEATURE! -// 二进制位(0|1) +// Bit Binary bit (0 | 1) 二进制位(0|1) type Bit int8 +// EncodeBits . +// Default coding // 默认编码 func EncodeBits(bits []Bit, i int, l int) []Bit { return EncodeBitsWithUint(bits, uint(i), l) } +// EncodeBitsWithUint . +// Merge ui bitwise into the bits array and occupy the length length bits (Note: binary 0 | 1 digits are stored in the uis array) // 将ui按位合并到bits数组中,并占length长度位(注意:uis数组中存放的是二进制的0|1数字) func EncodeBitsWithUint(bits []Bit, ui uint, l int) []Bit { a := make([]Bit, l) @@ -25,11 +29,12 @@ func EncodeBitsWithUint(bits []Bit, ui uint, l int) []Bit { } if bits != nil { return append(bits, a...) - } else { - return a } + return a } +// EncodeBitsToBytes . +// Convert bits to [] byte, encode from left to right, and add less than 1 byte from 0 to the end. // 将bits转换为[]byte,从左至右进行编码,不足1 byte按0往末尾补充 func EncodeBitsToBytes(bits []Bit) []byte { if len(bits)%8 != 0 { @@ -44,6 +49,8 @@ func EncodeBitsToBytes(bits []Bit) []byte { return b } +// DecodeBits . +// Resolve to int // 解析为int func DecodeBits(bits []Bit) int { v := 0 @@ -53,6 +60,8 @@ func DecodeBits(bits []Bit) int { return v } +// DecodeBitsToUint . +// Resolve to uint // 解析为uint func DecodeBitsToUint(bits []Bit) uint { v := uint(0) @@ -62,6 +71,8 @@ func DecodeBitsToUint(bits []Bit) uint { return v } +// DecodeBytesToBits . +// Parsing [] byte into character array [] uint8 // 解析[]byte为字位数组[]uint8 func DecodeBytesToBits(bs []byte) []Bit { bits := make([]Bit, 0) diff --git a/encoding/gcharset/gcharset.go b/encoding/gcharset/gcharset.go index 676821195..534f84aa3 100644 --- a/encoding/gcharset/gcharset.go +++ b/encoding/gcharset/gcharset.go @@ -22,11 +22,11 @@ package gcharset import ( "bytes" "context" + "io/ioutil" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" - "io/ioutil" - "golang.org/x/text/encoding" "golang.org/x/text/encoding/ianaindex" "golang.org/x/text/transform" diff --git a/encoding/gcompress/gcompress_gzip.go b/encoding/gcompress/gcompress_gzip.go index b7b44a49f..0ce292534 100644 --- a/encoding/gcompress/gcompress_gzip.go +++ b/encoding/gcompress/gcompress_gzip.go @@ -9,8 +9,9 @@ package gcompress import ( "bytes" "compress/gzip" - "github.com/gogf/gf/v2/os/gfile" "io" + + "github.com/gogf/gf/v2/os/gfile" ) // Gzip compresses `data` using gzip algorithm. @@ -91,7 +92,7 @@ func UnGzip(data []byte) ([]byte, error) { return buf.Bytes(), nil } -// UnGzip decompresses file `src` to `dst` using gzip algorithm. +// UnGzipFile decompresses file `src` to `dst` using gzip algorithm. func UnGzipFile(src, dst string) error { srcFile, err := gfile.Open(src) if err != nil { diff --git a/encoding/gcompress/gcompress_z_unit_gzip_test.go b/encoding/gcompress/gcompress_z_unit_gzip_test.go index 319b92a0d..19e6d6698 100644 --- a/encoding/gcompress/gcompress_z_unit_gzip_test.go +++ b/encoding/gcompress/gcompress_z_unit_gzip_test.go @@ -7,12 +7,12 @@ package gcompress_test import ( - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/os/gtime" "testing" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/encoding/gcompress" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/encoding/gcompress/gcompress_z_unit_zip_test.go b/encoding/gcompress/gcompress_z_unit_zip_test.go index c82428c6e..0cd3348d6 100644 --- a/encoding/gcompress/gcompress_z_unit_zip_test.go +++ b/encoding/gcompress/gcompress_z_unit_zip_test.go @@ -8,12 +8,12 @@ package gcompress_test import ( "bytes" + "testing" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/encoding/gcompress" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" - "testing" - "github.com/gogf/gf/v2/test/gtest" ) diff --git a/encoding/gcompress/gcompress_zip.go b/encoding/gcompress/gcompress_zip.go index 74a255de7..a9ee32bf0 100644 --- a/encoding/gcompress/gcompress_zip.go +++ b/encoding/gcompress/gcompress_zip.go @@ -10,13 +10,14 @@ import ( "archive/zip" "bytes" "context" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/text/gstr" "io" "os" "path/filepath" "strings" + + "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/text/gstr" ) // ZipPath compresses `paths` to `dest` using zip compressing algorithm. diff --git a/encoding/ghtml/ghtml_test.go b/encoding/ghtml/ghtml_test.go index 9d3af14a1..0c70e2a85 100644 --- a/encoding/ghtml/ghtml_test.go +++ b/encoding/ghtml/ghtml_test.go @@ -7,10 +7,10 @@ package ghtml_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" "github.com/gogf/gf/v2/encoding/ghtml" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/encoding/gini/gini.go b/encoding/gini/gini.go index 55b5325cf..733d9385f 100644 --- a/encoding/gini/gini.go +++ b/encoding/gini/gini.go @@ -11,11 +11,12 @@ import ( "bufio" "bytes" "fmt" + "io" + "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" - "io" - "strings" ) // Decode converts INI format to map. diff --git a/encoding/gini/gini_test.go b/encoding/gini/gini_test.go index e080d8900..2a3239bce 100644 --- a/encoding/gini/gini_test.go +++ b/encoding/gini/gini_test.go @@ -7,10 +7,11 @@ package gini_test import ( + "testing" + "github.com/gogf/gf/v2/encoding/gini" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/test/gtest" - "testing" ) var iniContent = ` diff --git a/encoding/gjson/gjson.go b/encoding/gjson/gjson.go index 392dfb2bd..622d45793 100644 --- a/encoding/gjson/gjson.go +++ b/encoding/gjson/gjson.go @@ -8,12 +8,12 @@ package gjson import ( - "github.com/gogf/gf/v2/internal/utils" "reflect" "strconv" "strings" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/encoding/gjson/gjson_api.go b/encoding/gjson/gjson_api.go index b08a13947..c08c75d15 100644 --- a/encoding/gjson/gjson_api.go +++ b/encoding/gjson/gjson_api.go @@ -8,11 +8,11 @@ package gjson import ( "fmt" + + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/util/gutil" - - "github.com/gogf/gf/v2/container/gvar" ) // Interface returns the json value. diff --git a/encoding/gjson/gjson_api_new_load.go b/encoding/gjson/gjson_api_new_load.go index 3bbc6d912..78eb38c25 100644 --- a/encoding/gjson/gjson_api_new_load.go +++ b/encoding/gjson/gjson_api_new_load.go @@ -8,18 +8,17 @@ package gjson import ( "bytes" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/utils" "reflect" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/encoding/gini" "github.com/gogf/gf/v2/encoding/gtoml" "github.com/gogf/gf/v2/encoding/gxml" "github.com/gogf/gf/v2/encoding/gyaml" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" + "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/util/gconv" @@ -178,7 +177,7 @@ func LoadContentType(dataType string, data interface{}, safe ...bool) (*Json, er if len(content) == 0 { return New(nil, safe...), nil } - //ignore UTF8-BOM + // ignore UTF8-BOM if content[0] == 0xEF && content[1] == 0xBB && content[2] == 0xBF { content = content[3:] } @@ -217,7 +216,7 @@ func loadContentTypeWithOptions(dataType string, data interface{}, options Optio if len(content) == 0 { return NewWithOptions(nil, options), nil } - //ignore UTF8-BOM + // ignore UTF8-BOM if content[0] == 0xEF && content[1] == 0xBB && content[2] == 0xBF { content = content[3:] } diff --git a/encoding/gjson/gjson_stdlib_json_util.go b/encoding/gjson/gjson_stdlib_json_util.go index 33d7c7481..097d9cff2 100644 --- a/encoding/gjson/gjson_stdlib_json_util.go +++ b/encoding/gjson/gjson_stdlib_json_util.go @@ -8,6 +8,7 @@ package gjson import ( "bytes" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/util/gconv" ) @@ -43,7 +44,7 @@ func DecodeTo(data interface{}, v interface{}) error { // Do not use number, it converts float64 to json.Number type, // which actually a string type. It causes converting issue for other data formats, // for example: yaml. - //decoder.UseNumber() + // decoder.UseNumber() return decoder.Decode(v) } diff --git a/encoding/gjson/gjson_z_example_conversion_test.go b/encoding/gjson/gjson_z_example_conversion_test.go index 9c3ec2f90..4fbfa05a6 100644 --- a/encoding/gjson/gjson_z_example_conversion_test.go +++ b/encoding/gjson/gjson_z_example_conversion_test.go @@ -8,6 +8,7 @@ package gjson_test import ( "fmt" + "github.com/gogf/gf/v2/encoding/gjson" ) diff --git a/encoding/gjson/gjson_z_example_dataset_test.go b/encoding/gjson/gjson_z_example_dataset_test.go index 779dc4493..a15ef4c80 100644 --- a/encoding/gjson/gjson_z_example_dataset_test.go +++ b/encoding/gjson/gjson_z_example_dataset_test.go @@ -8,6 +8,7 @@ package gjson_test import ( "fmt" + "github.com/gogf/gf/v2/encoding/gjson" ) diff --git a/encoding/gjson/gjson_z_example_load_test.go b/encoding/gjson/gjson_z_example_load_test.go index 4a304a846..84deb1fee 100644 --- a/encoding/gjson/gjson_z_example_load_test.go +++ b/encoding/gjson/gjson_z_example_load_test.go @@ -8,6 +8,7 @@ package gjson_test import ( "fmt" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/encoding/gjson" ) diff --git a/encoding/gjson/gjson_z_example_new_test.go b/encoding/gjson/gjson_z_example_new_test.go index 9aee73f85..644e567c4 100644 --- a/encoding/gjson/gjson_z_example_new_test.go +++ b/encoding/gjson/gjson_z_example_new_test.go @@ -8,6 +8,7 @@ package gjson_test import ( "fmt" + "github.com/gogf/gf/v2/encoding/gjson" ) diff --git a/encoding/gjson/gjson_z_example_pattern_test.go b/encoding/gjson/gjson_z_example_pattern_test.go index 6a8b8b49c..e6bc4aa91 100644 --- a/encoding/gjson/gjson_z_example_pattern_test.go +++ b/encoding/gjson/gjson_z_example_pattern_test.go @@ -8,6 +8,7 @@ package gjson_test import ( "fmt" + "github.com/gogf/gf/v2/encoding/gjson" ) diff --git a/encoding/gjson/gjson_z_unit_basic_test.go b/encoding/gjson/gjson_z_unit_basic_test.go index 88c47cd48..dfdc2cc55 100644 --- a/encoding/gjson/gjson_z_unit_basic_test.go +++ b/encoding/gjson/gjson_z_unit_basic_test.go @@ -7,9 +7,9 @@ package gjson_test import ( - "github.com/gogf/gf/v2/container/gmap" "testing" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" @@ -372,7 +372,7 @@ func Test_Convert2(t *testing.T) { err := j.Var().Scan(&name) t.Assert(err, nil) t.Assert(name.Name, "gf") - //j.Dump() + // j.Dump() t.Assert(err, nil) j = gjson.New(`{"person":{"name":"gf"}}`) @@ -381,7 +381,7 @@ func Test_Convert2(t *testing.T) { t.Assert(name.Name, "gf") j = gjson.New(`{"name":"gf""}`) - //j.Dump() + // j.Dump() t.Assert(err, nil) j = gjson.New(`[1,2,3]`) diff --git a/encoding/gjson/gjson_z_unit_implements_test.go b/encoding/gjson/gjson_z_unit_implements_test.go index a38eec1a9..a29f8244a 100644 --- a/encoding/gjson/gjson_z_unit_implements_test.go +++ b/encoding/gjson/gjson_z_unit_implements_test.go @@ -7,13 +7,13 @@ package gjson_test import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" "testing" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func TestJson_UnmarshalJSON(t *testing.T) { diff --git a/encoding/gjson/gjson_z_unit_internal_test.go b/encoding/gjson/gjson_z_unit_internal_test.go index b195fc342..853b839c0 100644 --- a/encoding/gjson/gjson_z_unit_internal_test.go +++ b/encoding/gjson/gjson_z_unit_internal_test.go @@ -7,8 +7,9 @@ package gjson import ( - "github.com/gogf/gf/v2/test/gtest" "testing" + + "github.com/gogf/gf/v2/test/gtest" ) func Test_checkDataType(t *testing.T) { @@ -80,11 +81,11 @@ dd = 11 "gf.gvalid.rule.not-in" = "The :attribute value is not in acceptable range" "gf.gvalid.rule.regex" = "The :attribute value is invalid" `) - //fmt.Println(gregex.IsMatch(`^[\s\t\n\r]*[\w\-]+\s*:\s*".+"`, data)) - //fmt.Println(gregex.IsMatch(`^[\s\t\n\r]*[\w\-]+\s*:\s*\w+`, data)) - //fmt.Println(gregex.IsMatch(`[\s\t\n\r]+[\w\-]+\s*:\s*".+"`, data)) - //fmt.Println(gregex.IsMatch(`[\n\r]+[\w\-\s\t]+\s*:\s*\w+`, data)) - //fmt.Println(gregex.MatchString(`[\n\r]+[\w\-\s\t]+\s*:\s*\w+`, string(data))) + // fmt.Println(gregex.IsMatch(`^[\s\t\n\r]*[\w\-]+\s*:\s*".+"`, data)) + // fmt.Println(gregex.IsMatch(`^[\s\t\n\r]*[\w\-]+\s*:\s*\w+`, data)) + // fmt.Println(gregex.IsMatch(`[\s\t\n\r]+[\w\-]+\s*:\s*".+"`, data)) + // fmt.Println(gregex.IsMatch(`[\n\r]+[\w\-\s\t]+\s*:\s*\w+`, data)) + // fmt.Println(gregex.MatchString(`[\n\r]+[\w\-\s\t]+\s*:\s*\w+`, string(data))) t.Assert(checkDataType(data), "toml") }) diff --git a/encoding/gjson/gjson_z_unit_json_test.go b/encoding/gjson/gjson_z_unit_json_test.go index aaf5f00bd..7a9b0429e 100644 --- a/encoding/gjson/gjson_z_unit_json_test.go +++ b/encoding/gjson/gjson_z_unit_json_test.go @@ -7,11 +7,12 @@ package gjson_test import ( + "testing" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" ) func Test_ToJson(t *testing.T) { diff --git a/encoding/gjson/gjson_z_unit_set_test.go b/encoding/gjson/gjson_z_unit_set_test.go index 6b1b340c1..c1d22926c 100644 --- a/encoding/gjson/gjson_z_unit_set_test.go +++ b/encoding/gjson/gjson_z_unit_set_test.go @@ -8,12 +8,12 @@ package gjson_test import ( "bytes" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/test/gtest" - "github.com/gogf/gf/v2/text/gstr" "testing" "github.com/gogf/gf/v2/encoding/gjson" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" ) func Test_Set1(t *testing.T) { diff --git a/encoding/gjson/gjson_z_unit_struct_test.go b/encoding/gjson/gjson_z_unit_struct_test.go index 0cc00d3c7..f6e2b7415 100644 --- a/encoding/gjson/gjson_z_unit_struct_test.go +++ b/encoding/gjson/gjson_z_unit_struct_test.go @@ -7,9 +7,10 @@ package gjson_test import ( + "testing" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func Test_GetScan(t *testing.T) { diff --git a/encoding/gtoml/gtoml.go b/encoding/gtoml/gtoml.go index d04d14897..23fc52af0 100644 --- a/encoding/gtoml/gtoml.go +++ b/encoding/gtoml/gtoml.go @@ -9,9 +9,9 @@ package gtoml import ( "bytes" - "github.com/gogf/gf/v2/internal/json" "github.com/BurntSushi/toml" + "github.com/gogf/gf/v2/internal/json" ) func Encode(v interface{}) ([]byte, error) { diff --git a/encoding/gtoml/gtoml_test.go b/encoding/gtoml/gtoml_test.go index a133b1d38..9a051e074 100644 --- a/encoding/gtoml/gtoml_test.go +++ b/encoding/gtoml/gtoml_test.go @@ -6,10 +6,11 @@ package gtoml_test import ( + "testing" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/encoding/gtoml" "github.com/gogf/gf/v2/test/gtest" - "testing" ) var tomlStr string = ` diff --git a/encoding/gxml/gxml_test.go b/encoding/gxml/gxml_test.go index 6d4b18c62..35a80e32a 100644 --- a/encoding/gxml/gxml_test.go +++ b/encoding/gxml/gxml_test.go @@ -8,11 +8,11 @@ package gxml_test import ( "bytes" - "github.com/gogf/gf/v2/encoding/gjson" "strings" "testing" "github.com/gogf/gf/v2/encoding/gcharset" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/encoding/gxml" "github.com/gogf/gf/v2/test/gtest" ) @@ -146,7 +146,7 @@ func Test_Encode(t *testing.T) { if err != nil { t.Errorf("encode error.") } - //t.Logf("%s\n", string(xmlStr)) + // t.Logf("%s\n", string(xmlStr)) res := `true100.92123hello world` if string(xmlStr) != res { @@ -169,7 +169,7 @@ func Test_EncodeIndent(t *testing.T) { t.Errorf("encodeWithIndent error.") } - //t.Logf("%s\n", string(xmlStr)) + // t.Logf("%s\n", string(xmlStr)) } diff --git a/encoding/gyaml/gyaml.go b/encoding/gyaml/gyaml.go index 3dfe52879..4a9cbe234 100644 --- a/encoding/gyaml/gyaml.go +++ b/encoding/gyaml/gyaml.go @@ -10,9 +10,8 @@ package gyaml import ( "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" - "gopkg.in/yaml.v3" - "github.com/gogf/gf/v2/util/gconv" + "gopkg.in/yaml.v3" ) func Encode(value interface{}) (out []byte, err error) { diff --git a/encoding/gyaml/gyaml_test.go b/encoding/gyaml/gyaml_test.go index 5e9983d41..2e4c8c666 100644 --- a/encoding/gyaml/gyaml_test.go +++ b/encoding/gyaml/gyaml_test.go @@ -7,13 +7,12 @@ package gyaml_test import ( - "github.com/gogf/gf/v2/encoding/gjson" - "github.com/gogf/gf/v2/internal/json" "testing" - "github.com/gogf/gf/v2/frame/g" - + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/encoding/gyaml" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/errors/gcode/gcode_test.go b/errors/gcode/gcode_test.go index 0ce6e34bc..b8690455f 100644 --- a/errors/gcode/gcode_test.go +++ b/errors/gcode/gcode_test.go @@ -7,9 +7,9 @@ package gcode_test import ( - "github.com/gogf/gf/v2/errors/gcode" "testing" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/errors/gerror/gerror.go b/errors/gerror/gerror.go index b5eb012f3..23be7df27 100644 --- a/errors/gerror/gerror.go +++ b/errors/gerror/gerror.go @@ -12,6 +12,7 @@ package gerror import ( "fmt" + "github.com/gogf/gf/v2/errors/gcode" ) diff --git a/errors/gerror/gerror_error.go b/errors/gerror/gerror_error.go index a500bb195..55111edab 100644 --- a/errors/gerror/gerror_error.go +++ b/errors/gerror/gerror_error.go @@ -10,11 +10,12 @@ import ( "bytes" "errors" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/internal/utils" "io" "runtime" "strings" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/internal/utils" ) // Error is custom error for additional features. diff --git a/errors/gerror/gerror_z_bench_test.go b/errors/gerror/gerror_z_bench_test.go index db0cab491..5046b8a4d 100644 --- a/errors/gerror/gerror_z_bench_test.go +++ b/errors/gerror/gerror_z_bench_test.go @@ -8,9 +8,10 @@ package gerror_test import ( "errors" + "testing" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "testing" ) var ( diff --git a/errors/gerror/gerror_z_example_test.go b/errors/gerror/gerror_z_example_test.go index 7423855ea..e43338e9c 100644 --- a/errors/gerror/gerror_z_example_test.go +++ b/errors/gerror/gerror_z_example_test.go @@ -9,6 +9,7 @@ package gerror_test import ( "errors" "fmt" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" ) diff --git a/errors/gerror/gerror_z_unit_test.go b/errors/gerror/gerror_z_unit_test.go index e5c790999..f4aa6b2df 100644 --- a/errors/gerror/gerror_z_unit_test.go +++ b/errors/gerror/gerror_z_unit_test.go @@ -9,11 +9,11 @@ package gerror_test import ( "errors" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/internal/json" "testing" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" ) @@ -209,13 +209,13 @@ func Test_Stack(t *testing.T) { err = gerror.Wrap(err, "2") err = gerror.Wrap(err, "3") t.AssertNE(err, nil) - //fmt.Printf("%+v", err) + // fmt.Printf("%+v", err) }) gtest.C(t, func(t *gtest.T) { err := gerror.New("1") t.AssertNE(fmt.Sprintf("%+v", err), "1") - //fmt.Printf("%+v", err) + // fmt.Printf("%+v", err) }) gtest.C(t, func(t *gtest.T) { @@ -223,7 +223,7 @@ func Test_Stack(t *testing.T) { err = gerror.Wrap(err, "2") err = gerror.Wrap(err, "3") t.AssertNE(err, nil) - //fmt.Printf("%+v", err) + // fmt.Printf("%+v", err) }) } diff --git a/frame/g/g.go b/frame/g/g.go index 9cad10f3b..e2e6d2f3f 100644 --- a/frame/g/g.go +++ b/frame/g/g.go @@ -8,6 +8,7 @@ package g import ( "context" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/util/gmeta" ) diff --git a/frame/g/g_func.go b/frame/g/g_func.go index 0c4887dfc..4d90b9f79 100644 --- a/frame/g/g_func.go +++ b/frame/g/g_func.go @@ -8,6 +8,7 @@ package g import ( "context" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/net/ghttp" diff --git a/frame/gins/gins_database.go b/frame/gins/gins_database.go index a1d57e99d..e807188fc 100644 --- a/frame/gins/gins_database.go +++ b/frame/gins/gins_database.go @@ -9,16 +9,16 @@ package gins import ( "context" "fmt" + + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gcfg" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/util/gutil" - - "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gutil" ) const ( diff --git a/frame/gins/gins_log.go b/frame/gins/gins_log.go index cbe175d58..a1a3938f0 100644 --- a/frame/gins/gins_log.go +++ b/frame/gins/gins_log.go @@ -9,6 +9,7 @@ package gins import ( "context" "fmt" + "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/frame/gins/gins_redis.go b/frame/gins/gins_redis.go index 9bc4afcfa..6d67b59ac 100644 --- a/frame/gins/gins_redis.go +++ b/frame/gins/gins_redis.go @@ -9,6 +9,7 @@ package gins import ( "context" "fmt" + "github.com/gogf/gf/v2/database/gredis" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" diff --git a/frame/gins/gins_server.go b/frame/gins/gins_server.go index e2f35cf46..4c176d373 100644 --- a/frame/gins/gins_server.go +++ b/frame/gins/gins_server.go @@ -9,6 +9,7 @@ package gins import ( "context" "fmt" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/util/gconv" diff --git a/frame/gins/gins_view.go b/frame/gins/gins_view.go index bc62d19aa..b9e3b0e6a 100644 --- a/frame/gins/gins_view.go +++ b/frame/gins/gins_view.go @@ -9,6 +9,7 @@ package gins import ( "context" "fmt" + "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/frame/gins/gins_z_unit_basic_test.go b/frame/gins/gins_z_unit_basic_test.go index c6ef3b01f..f6a674e70 100644 --- a/frame/gins/gins_z_unit_basic_test.go +++ b/frame/gins/gins_z_unit_basic_test.go @@ -7,9 +7,9 @@ package gins_test import ( - "github.com/gogf/gf/v2/frame/gins" "testing" + "github.com/gogf/gf/v2/frame/gins" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/frame/gins/gins_z_unit_config_test.go b/frame/gins/gins_z_unit_config_test.go index 38099d311..848cbd92a 100644 --- a/frame/gins/gins_z_unit_config_test.go +++ b/frame/gins/gins_z_unit_config_test.go @@ -9,13 +9,12 @@ package gins_test import ( "context" "fmt" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/frame/gins" "testing" "time" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/frame/gins" "github.com/gogf/gf/v2/os/gcfg" - "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" diff --git a/frame/gins/gins_z_unit_database_test.go b/frame/gins/gins_z_unit_database_test.go index edd76427c..622e10fed 100644 --- a/frame/gins/gins_z_unit_database_test.go +++ b/frame/gins/gins_z_unit_database_test.go @@ -7,14 +7,14 @@ package gins_test import ( - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/frame/gins" - "github.com/gogf/gf/v2/os/gcfg" - "github.com/gogf/gf/v2/os/gtime" "testing" "time" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/frame/gins" + "github.com/gogf/gf/v2/os/gcfg" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) @@ -41,7 +41,7 @@ func Test_Database(t *testing.T) { // for gfsnotify callbacks to refresh cache of config file time.Sleep(500 * time.Millisecond) - //fmt.Println("gins Test_Database", Config().Get("test")) + // fmt.Println("gins Test_Database", Config().Get("test")) dbDefault := gins.Database() dbTest := gins.Database("test") diff --git a/frame/gins/gins_z_unit_redis_test.go b/frame/gins/gins_z_unit_redis_test.go index cc2bfa417..f69936622 100644 --- a/frame/gins/gins_z_unit_redis_test.go +++ b/frame/gins/gins_z_unit_redis_test.go @@ -7,14 +7,14 @@ package gins_test import ( - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/frame/gins" - "github.com/gogf/gf/v2/os/gcfg" - "github.com/gogf/gf/v2/os/gtime" "testing" "time" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/frame/gins" + "github.com/gogf/gf/v2/os/gcfg" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) @@ -42,7 +42,7 @@ func Test_Redis(t *testing.T) { // for gfsnotify callbacks to refresh cache of config file time.Sleep(500 * time.Millisecond) - //fmt.Println("gins Test_Redis", Config().Get("test")) + // fmt.Println("gins Test_Redis", Config().Get("test")) var ( redisDefault = gins.Redis() diff --git a/frame/gins/gins_z_unit_view_test.go b/frame/gins/gins_z_unit_view_test.go index c77f64fb0..f14c10f70 100644 --- a/frame/gins/gins_z_unit_view_test.go +++ b/frame/gins/gins_z_unit_view_test.go @@ -9,10 +9,10 @@ package gins import ( "context" "fmt" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/os/gcfg" "testing" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/os/gcfg" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" diff --git a/go.mod b/go.mod index 002be54d1..9f792ae5e 100644 --- a/go.mod +++ b/go.mod @@ -5,16 +5,16 @@ go 1.14 require ( github.com/BurntSushi/toml v0.4.1 github.com/clbanning/mxj/v2 v2.5.5 - github.com/fatih/color v1.12.0 + github.com/fatih/color v1.13.0 github.com/fsnotify/fsnotify v1.5.1 - github.com/go-redis/redis/v8 v8.11.3 + github.com/go-redis/redis/v8 v8.11.4 github.com/go-sql-driver/mysql v1.6.0 github.com/gorilla/websocket v1.4.2 github.com/grokify/html-strip-tags-go v0.0.1 github.com/olekukonko/tablewriter v0.0.5 - go.opentelemetry.io/otel v1.0.0 - go.opentelemetry.io/otel/trace v1.0.0 - golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 - golang.org/x/text v0.3.6 + go.opentelemetry.io/otel v1.2.0 + go.opentelemetry.io/otel/trace v1.2.0 + golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 + golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) diff --git a/go.sum b/go.sum index af0926c5d..285db7672 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw= github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/clbanning/mxj/v2 v2.5.5 h1:oT81vUeEiQQ/DcHbzSytRngP6Ky9O+L+0Bw0zSJag9E= github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -9,14 +9,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc= -github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= -github.com/go-redis/redis/v8 v8.11.3 h1:GCjoYp8c+yQTJfc0n69iwSiHjvuAdruxl7elnZCxgt8= -github.com/go-redis/redis/v8 v8.11.3/go.mod h1:xNJ9xDG09FsIPwh3bWdk+0oDWHbtF9rPN0F/oD9XeKc= +github.com/go-redis/redis/v8 v8.11.4 h1:kHoYkfZP6+pe04aFTnhDH6GDROa5yJdHJVNxV3F46Tg= +github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -41,10 +41,11 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0= github.com/grokify/html-strip-tags-go v0.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= -github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= @@ -58,8 +59,8 @@ github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.15.0 h1:WjP/FQ/sk43MRmnEcT+MlDw2TFvkrXlprrPST/IudjU= -github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= +github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c= +github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -67,25 +68,29 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/otel v1.0.0 h1:qTTn6x71GVBvoafHK/yaRUmFzI4LcONZD0/kXxl5PHI= -go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg= -go.opentelemetry.io/otel/trace v1.0.0 h1:TSBr8GTEtKevYMG/2d21M989r5WJYVimhTHBKVEZuh4= -go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.opentelemetry.io/otel v1.2.0 h1:YOQDvxO1FayUcT9MIhJhgMyNO1WqoduiyvQHzGN0kUQ= +go.opentelemetry.io/otel v1.2.0/go.mod h1:aT17Fk0Z1Nor9e0uisf98LrntPGMnk4frBO9+dkf69I= +go.opentelemetry.io/otel/trace v1.2.0 h1:Ys3iqbqZhcf28hHzrm5WAquMkDHNZTUkw7KHbuNjej0= +go.opentelemetry.io/otel/trace v1.2.0/go.mod h1:N5FLswTubnxKxOJHM7XZC074qpeEdLy3CgAVsdMucK0= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 h1:ADo5wSpq2gqaCGQWzk7S5vd//0iyyLeAratkEoG5dLE= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -99,16 +104,19 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2 h1:GLw7MR8AfAG2GmGcmVgObFOHXYypgGjnGno25RDwn3Y= +golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2/go.mod h1:EFNZuWvGYxIRUEX+K8UmCFwYmZjqcrnq15ZuVldZkZ0= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -133,7 +141,6 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/i18n/gi18n/gi18n_manager.go b/i18n/gi18n/gi18n_manager.go index 81bc954f0..b632734af 100644 --- a/i18n/gi18n/gi18n_manager.go +++ b/i18n/gi18n/gi18n_manager.go @@ -9,22 +9,18 @@ package gi18n import ( "context" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" "strings" "sync" - "github.com/gogf/gf/v2/os/gfsnotify" - - "github.com/gogf/gf/v2/text/gregex" - - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/encoding/gjson" - + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gfsnotify" "github.com/gogf/gf/v2/os/gres" + "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/util/gconv" ) // Manager for i18n contents, it is concurrent safe, supporting hot reload. diff --git a/i18n/gi18n/gi18n_unit_test.go b/i18n/gi18n/gi18n_unit_test.go index 7ea3d21b2..c7d5cf22b 100644 --- a/i18n/gi18n/gi18n_unit_test.go +++ b/i18n/gi18n/gi18n_unit_test.go @@ -10,21 +10,15 @@ import ( "context" "testing" - "github.com/gogf/gf/v2/os/gres" - - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv" - - "github.com/gogf/gf/v2/frame/g" - - "github.com/gogf/gf/v2/i18n/gi18n" - "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/i18n/gi18n" "github.com/gogf/gf/v2/os/gfile" - - "github.com/gogf/gf/v2/test/gtest" - + "github.com/gogf/gf/v2/os/gres" _ "github.com/gogf/gf/v2/os/gres/testdata/data" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_Basic(t *testing.T) { diff --git a/internal/intlog/intlog.go b/internal/intlog/intlog.go index e49f6d2c5..5247f75bc 100644 --- a/internal/intlog/intlog.go +++ b/internal/intlog/intlog.go @@ -11,11 +11,12 @@ import ( "bytes" "context" "fmt" + "path/filepath" + "time" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/internal/utils" "go.opentelemetry.io/otel/trace" - "path/filepath" - "time" ) const ( diff --git a/internal/utils/utils_is.go b/internal/utils/utils_is.go index ceb4f74e8..b9655b633 100644 --- a/internal/utils/utils_is.go +++ b/internal/utils/utils_is.go @@ -7,8 +7,9 @@ package utils import ( - "github.com/gogf/gf/v2/internal/empty" "reflect" + + "github.com/gogf/gf/v2/internal/empty" ) // IsNil checks whether `value` is nil. diff --git a/internal/utils/utils_z_bench_test.go b/internal/utils/utils_z_bench_test.go index fa6c0fcd9..4ad988c28 100644 --- a/internal/utils/utils_z_bench_test.go +++ b/internal/utils/utils_z_bench_test.go @@ -7,9 +7,10 @@ package utils_test import ( - "github.com/gogf/gf/v2/internal/utils" "regexp" "testing" + + "github.com/gogf/gf/v2/internal/utils" ) var ( diff --git a/internal/utils/utils_z_is_test.go b/internal/utils/utils_z_is_test.go index 5b06a70e2..46ac53f3a 100644 --- a/internal/utils/utils_z_is_test.go +++ b/internal/utils/utils_z_is_test.go @@ -7,10 +7,11 @@ package utils_test import ( + "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func TestVar_IsNil(t *testing.T) { diff --git a/internal/utils/utils_z_test.go b/internal/utils/utils_z_test.go index 27e1892a8..5201e80e1 100644 --- a/internal/utils/utils_z_test.go +++ b/internal/utils/utils_z_test.go @@ -7,11 +7,12 @@ package utils_test import ( - "github.com/gogf/gf/v2/internal/utils" - "github.com/gogf/gf/v2/test/gtest" "io/ioutil" "reflect" "testing" + + "github.com/gogf/gf/v2/internal/utils" + "github.com/gogf/gf/v2/test/gtest" ) func Test_ReadCloser(t *testing.T) { diff --git a/net/ghttp/ghttp.go b/net/ghttp/ghttp.go index 3700112df..0b60cf717 100644 --- a/net/ghttp/ghttp.go +++ b/net/ghttp/ghttp.go @@ -8,15 +8,16 @@ package ghttp import ( + "net/http" + "reflect" + "time" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/os/gcache" "github.com/gogf/gf/v2/os/gsession" "github.com/gogf/gf/v2/protocol/goai" "github.com/gorilla/websocket" - "net/http" - "reflect" - "time" ) type ( diff --git a/net/ghttp/ghttp_client_websocket.go b/net/ghttp/ghttp_client_websocket.go index 1f1f228f7..cf99c29e1 100644 --- a/net/ghttp/ghttp_client_websocket.go +++ b/net/ghttp/ghttp_client_websocket.go @@ -7,9 +7,10 @@ package ghttp import ( - "github.com/gorilla/websocket" "net/http" "time" + + "github.com/gorilla/websocket" ) // WebSocketClient wraps the underlying websocket client connection diff --git a/net/ghttp/ghttp_middleware_tracing.go b/net/ghttp/ghttp_middleware_tracing.go index 8826edf15..f7c71a512 100644 --- a/net/ghttp/ghttp_middleware_tracing.go +++ b/net/ghttp/ghttp_middleware_tracing.go @@ -80,13 +80,7 @@ func MiddlewareServerTracing(r *Request) { span.SetStatus(codes.Error, fmt.Sprintf(`%+v`, err)) } // Response content logging. - var resBodyContent string - resBodyContent = r.Response.BufferString() - resBodyContent = gstr.StrLimit( - r.Response.BufferString(), - gtrace.MaxContentLogSize(), - "...", - ) + var resBodyContent = gstr.StrLimit(r.Response.BufferString(), gtrace.MaxContentLogSize(), "...") span.AddEvent(tracingEventHttpResponse, trace.WithAttributes( attribute.String(tracingEventHttpResponseHeaders, gconv.String(httputil.HeaderToMap(r.Response.Header()))), diff --git a/net/ghttp/ghttp_request.go b/net/ghttp/ghttp_request.go index 302d05f5d..cb4a9d085 100644 --- a/net/ghttp/ghttp_request.go +++ b/net/ghttp/ghttp_request.go @@ -16,11 +16,10 @@ import ( "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gres" "github.com/gogf/gf/v2/os/gsession" - "github.com/gogf/gf/v2/os/gview" - "github.com/gogf/gf/v2/util/guid" - "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/util/guid" ) // Request is the context object for a request. diff --git a/net/ghttp/ghttp_request_middleware.go b/net/ghttp/ghttp_request_middleware.go index 23bf8fc9a..3572d8d40 100644 --- a/net/ghttp/ghttp_request_middleware.go +++ b/net/ghttp/ghttp_request_middleware.go @@ -7,11 +7,11 @@ package ghttp import ( - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "net/http" "reflect" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/net/ghttp/ghttp_request_param.go b/net/ghttp/ghttp_request_param.go index c8ba8cbea..819bcbabe 100644 --- a/net/ghttp/ghttp_request_param.go +++ b/net/ghttp/ghttp_request_param.go @@ -9,6 +9,11 @@ package ghttp import ( "bytes" "fmt" + "io/ioutil" + "mime/multipart" + "reflect" + "strings" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/encoding/gurl" @@ -21,10 +26,6 @@ import ( "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gvalid" - "io/ioutil" - "mime/multipart" - "reflect" - "strings" ) const ( diff --git a/net/ghttp/ghttp_request_param_ctx.go b/net/ghttp/ghttp_request_param_ctx.go index e208e64b3..7c4760b56 100644 --- a/net/ghttp/ghttp_request_param_ctx.go +++ b/net/ghttp/ghttp_request_param_ctx.go @@ -8,6 +8,7 @@ package ghttp import ( "context" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/os/gctx" ) diff --git a/net/ghttp/ghttp_request_param_file.go b/net/ghttp/ghttp_request_param_file.go index 9c78b9551..9918c5c68 100644 --- a/net/ghttp/ghttp_request_param_file.go +++ b/net/ghttp/ghttp_request_param_file.go @@ -8,16 +8,17 @@ package ghttp import ( "context" + "io" + "mime/multipart" + "strconv" + "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/util/grand" - "io" - "mime/multipart" - "strconv" - "strings" ) // UploadFile wraps the multipart uploading file with more and convenient features. diff --git a/net/ghttp/ghttp_request_param_page.go b/net/ghttp/ghttp_request_param_page.go index 49c4f6461..8feda30eb 100644 --- a/net/ghttp/ghttp_request_param_page.go +++ b/net/ghttp/ghttp_request_param_page.go @@ -8,6 +8,7 @@ package ghttp import ( "fmt" + "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gpage" diff --git a/net/ghttp/ghttp_request_param_query.go b/net/ghttp/ghttp_request_param_query.go index dc943f1f8..70ed03f1d 100644 --- a/net/ghttp/ghttp_request_param_query.go +++ b/net/ghttp/ghttp_request_param_query.go @@ -8,7 +8,6 @@ package ghttp import ( "github.com/gogf/gf/v2/container/gvar" - "github.com/gogf/gf/v2/util/gconv" ) diff --git a/net/ghttp/ghttp_response.go b/net/ghttp/ghttp_response.go index 52975343d..533a40472 100644 --- a/net/ghttp/ghttp_response.go +++ b/net/ghttp/ghttp_response.go @@ -12,9 +12,8 @@ import ( "fmt" "net/http" - "github.com/gogf/gf/v2/os/gres" - "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gres" ) // Response is the http response manager. @@ -63,9 +62,10 @@ func (r *Response) ServeFile(path string, allowIndex ...bool) { // ServeFileDownload serves file downloading to the response. func (r *Response) ServeFileDownload(path string, name ...string) { var ( - serveFile *staticFile + serveFile *staticFile + downloadName = "" ) - downloadName := "" + if len(name) > 0 { downloadName = name[0] } diff --git a/net/ghttp/ghttp_response_cors.go b/net/ghttp/ghttp_response_cors.go index e74eb761c..f7dbfe107 100644 --- a/net/ghttp/ghttp_response_cors.go +++ b/net/ghttp/ghttp_response_cors.go @@ -8,10 +8,11 @@ package ghttp import ( - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/util/gconv" "net/http" "net/url" + + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" ) // CORSOptions is the options for CORS feature. @@ -105,7 +106,7 @@ func (r *Response) CORS(options CORSOptions) { } } -// CORSAllowed checks whether the current request origin is allowed cross-domain. +// CORSAllowedOrigin CORSAllowed checks whether the current request origin is allowed cross-domain. func (r *Response) CORSAllowedOrigin(options CORSOptions) bool { if options.AllowDomain == nil { return true diff --git a/net/ghttp/ghttp_response_write.go b/net/ghttp/ghttp_response_write.go index e8fb37b9d..038628b98 100644 --- a/net/ghttp/ghttp_response_write.go +++ b/net/ghttp/ghttp_response_write.go @@ -9,10 +9,11 @@ package ghttp import ( "fmt" + "net/http" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/util/gconv" - "net/http" ) // Write writes `content` to the response buffer. @@ -130,7 +131,7 @@ func (r *Response) WriteJsonExit(content interface{}) error { return nil } -// WriteJson writes `content` to the response with JSONP format. +// WriteJsonP writes `content` to the response with JSONP format. // // Note that there should be a "callback" parameter in the request for JSONP format. func (r *Response) WriteJsonP(content interface{}) error { @@ -145,7 +146,7 @@ func (r *Response) WriteJsonP(content interface{}) error { if b, err := json.Marshal(content); err != nil { return err } else { - //r.Header().Set("Content-Type", "application/json") + // r.Header().Set("Content-Type", "application/json") if callback := r.Request.Get("callback").String(); callback != "" { buffer := []byte(callback) buffer = append(buffer, byte('(')) diff --git a/net/ghttp/ghttp_response_writer.go b/net/ghttp/ghttp_response_writer.go index 7d87981ff..08ea3daee 100644 --- a/net/ghttp/ghttp_response_writer.go +++ b/net/ghttp/ghttp_response_writer.go @@ -50,7 +50,7 @@ func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { return w.writer.(http.Hijacker).Hijack() } -// OutputBuffer outputs the buffer to client and clears the buffer. +// Flush OutputBuffer outputs the buffer to client and clears the buffer. func (w *ResponseWriter) Flush() { if w.hijacked { return diff --git a/net/ghttp/ghttp_server.go b/net/ghttp/ghttp_server.go index e2d860a9e..9d2266d1f 100644 --- a/net/ghttp/ghttp_server.go +++ b/net/ghttp/ghttp_server.go @@ -10,30 +10,29 @@ import ( "bytes" "context" "fmt" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/net/ghttp/internal/swaggerui" - "github.com/gogf/gf/v2/protocol/goai" - "github.com/gogf/gf/v2/text/gstr" "net/http" "os" "runtime" "strings" "time" - "github.com/gogf/gf/v2/os/gsession" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/net/ghttp/internal/swaggerui" "github.com/gogf/gf/v2/os/gcache" "github.com/gogf/gf/v2/os/genv" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gproc" + "github.com/gogf/gf/v2/os/gsession" "github.com/gogf/gf/v2/os/gtimer" + "github.com/gogf/gf/v2/protocol/goai" "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/olekukonko/tablewriter" ) diff --git a/net/ghttp/ghttp_server_admin.go b/net/ghttp/ghttp_server_admin.go index f8e00350d..e84d8d886 100644 --- a/net/ghttp/ghttp_server_admin.go +++ b/net/ghttp/ghttp_server_admin.go @@ -8,10 +8,10 @@ package ghttp import ( "context" - "github.com/gogf/gf/v2/os/gfile" "strings" "time" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gproc" "github.com/gogf/gf/v2/os/gtimer" "github.com/gogf/gf/v2/os/gview" diff --git a/net/ghttp/ghttp_server_admin_process.go b/net/ghttp/ghttp_server_admin_process.go index 02702d56e..240aca38b 100644 --- a/net/ghttp/ghttp_server_admin_process.go +++ b/net/ghttp/ghttp_server_admin_process.go @@ -10,10 +10,6 @@ import ( "bytes" "context" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/text/gstr" "os" "runtime" "strings" @@ -22,10 +18,14 @@ import ( "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/encoding/gjson" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gproc" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtimer" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/net/ghttp/ghttp_server_admin_unix.go b/net/ghttp/ghttp_server_admin_unix.go index 43063d2b9..771e063d9 100644 --- a/net/ghttp/ghttp_server_admin_unix.go +++ b/net/ghttp/ghttp_server_admin_unix.go @@ -4,16 +4,18 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. +//go:build !windows // +build !windows package ghttp import ( "context" - "github.com/gogf/gf/v2/internal/intlog" "os" "os/signal" "syscall" + + "github.com/gogf/gf/v2/internal/intlog" ) // procSignalChan is the channel for listening the signal. diff --git a/net/ghttp/ghttp_server_config.go b/net/ghttp/ghttp_server_config.go index 7fa9f01de..7d3944718 100644 --- a/net/ghttp/ghttp_server_config.go +++ b/net/ghttp/ghttp_server_config.go @@ -9,21 +9,18 @@ package ghttp import ( "context" "crypto/tls" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/os/gres" - "github.com/gogf/gf/v2/util/gutil" "net/http" "strconv" "time" - "github.com/gogf/gf/v2/util/gconv" - - "github.com/gogf/gf/v2/os/gsession" - - "github.com/gogf/gf/v2/os/gview" - + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/glog" + "github.com/gogf/gf/v2/os/gres" + "github.com/gogf/gf/v2/os/gsession" + "github.com/gogf/gf/v2/os/gview" + "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gutil" ) const ( diff --git a/net/ghttp/ghttp_server_cookie.go b/net/ghttp/ghttp_server_cookie.go index 764421396..8275593d9 100644 --- a/net/ghttp/ghttp_server_cookie.go +++ b/net/ghttp/ghttp_server_cookie.go @@ -7,9 +7,10 @@ package ghttp import ( - "github.com/gogf/gf/v2/container/gvar" "net/http" "time" + + "github.com/gogf/gf/v2/container/gvar" ) // Cookie for HTTP COOKIE management. @@ -47,9 +48,9 @@ func (c *Cookie) init() { c.data = make(map[string]*cookieItem) c.response = c.request.Response // DO NOT ADD ANY DEFAULT COOKIE DOMAIN! - //if c.request.Server.GetCookieDomain() == "" { + // if c.request.Server.GetCookieDomain() == "" { // c.request.Server.GetCookieDomain() = c.request.GetHost() - //} + // } for _, v := range c.request.Cookies() { c.data[v.Name] = &cookieItem{ Cookie: v, diff --git a/net/ghttp/ghttp_server_error_logger.go b/net/ghttp/ghttp_server_error_logger.go index 5d2ca380d..7bc89a079 100644 --- a/net/ghttp/ghttp_server_error_logger.go +++ b/net/ghttp/ghttp_server_error_logger.go @@ -9,6 +9,7 @@ package ghttp import ( "bytes" "context" + "github.com/gogf/gf/v2/os/glog" ) diff --git a/net/ghttp/ghttp_server_graceful.go b/net/ghttp/ghttp_server_graceful.go index 66aed18b3..898043933 100644 --- a/net/ghttp/ghttp_server_graceful.go +++ b/net/ghttp/ghttp_server_graceful.go @@ -9,15 +9,16 @@ package ghttp import ( "context" "crypto/tls" + "log" + "net" + "net/http" + "os" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/os/gproc" "github.com/gogf/gf/v2/os/gres" "github.com/gogf/gf/v2/text/gstr" - "log" - "net" - "net/http" - "os" ) // gracefulServer wraps the net/http.Server with graceful reload/restart feature. diff --git a/net/ghttp/ghttp_server_handler.go b/net/ghttp/ghttp_server_handler.go index c52286631..b8e8e2359 100644 --- a/net/ghttp/ghttp_server_handler.go +++ b/net/ghttp/ghttp_server_handler.go @@ -7,23 +7,20 @@ package ghttp import ( - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/internal/intlog" "net/http" "os" "sort" "strings" - "github.com/gogf/gf/v2/text/gstr" - - "github.com/gogf/gf/v2/errors/gerror" - - "github.com/gogf/gf/v2/os/gres" - "github.com/gogf/gf/v2/encoding/ghtml" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gres" "github.com/gogf/gf/v2/os/gspath" "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/text/gstr" ) // ServeHTTP is the default handler for http request. diff --git a/net/ghttp/ghttp_server_log.go b/net/ghttp/ghttp_server_log.go index 6c5ad5ae7..80b29cd78 100644 --- a/net/ghttp/ghttp_server_log.go +++ b/net/ghttp/ghttp_server_log.go @@ -8,6 +8,7 @@ package ghttp import ( "fmt" + "github.com/gogf/gf/v2/errors/gerror" ) diff --git a/net/ghttp/ghttp_server_openapi.go b/net/ghttp/ghttp_server_openapi.go index 85076e8c9..c03175174 100644 --- a/net/ghttp/ghttp_server_openapi.go +++ b/net/ghttp/ghttp_server_openapi.go @@ -8,6 +8,7 @@ package ghttp import ( "context" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/protocol/goai" "github.com/gogf/gf/v2/text/gstr" diff --git a/net/ghttp/ghttp_server_pprof.go b/net/ghttp/ghttp_server_pprof.go index e466bda67..e3dd34369 100644 --- a/net/ghttp/ghttp_server_pprof.go +++ b/net/ghttp/ghttp_server_pprof.go @@ -7,11 +7,11 @@ package ghttp import ( - "github.com/gogf/gf/v2/internal/intlog" netpprof "net/http/pprof" runpprof "runtime/pprof" "strings" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gview" ) diff --git a/net/ghttp/ghttp_server_router.go b/net/ghttp/ghttp_server_router.go index 50be1545e..ecdcc5304 100644 --- a/net/ghttp/ghttp_server_router.go +++ b/net/ghttp/ghttp_server_router.go @@ -9,19 +9,18 @@ package ghttp import ( "context" "fmt" - "github.com/gogf/gf/v2/container/gtype" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/protocol/goai" - "github.com/gogf/gf/v2/util/gmeta" "reflect" "strings" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/container/glist" + "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/protocol/goai" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gmeta" ) const ( diff --git a/net/ghttp/ghttp_server_router_group.go b/net/ghttp/ghttp_server_router_group.go index 1e5d7d7e2..f08283b55 100644 --- a/net/ghttp/ghttp_server_router_group.go +++ b/net/ghttp/ghttp_server_router_group.go @@ -9,11 +9,11 @@ package ghttp import ( "context" "fmt" + "reflect" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/text/gstr" - "reflect" - "github.com/gogf/gf/v2/util/gconv" ) diff --git a/net/ghttp/ghttp_server_router_hook.go b/net/ghttp/ghttp_server_router_hook.go index 2be2dd087..467319a53 100644 --- a/net/ghttp/ghttp_server_router_hook.go +++ b/net/ghttp/ghttp_server_router_hook.go @@ -8,9 +8,10 @@ package ghttp import ( "context" - "github.com/gogf/gf/v2/debug/gdebug" "net/http" "reflect" + + "github.com/gogf/gf/v2/debug/gdebug" ) // BindHookHandler registers handler for specified hook. diff --git a/net/ghttp/ghttp_server_router_middleware.go b/net/ghttp/ghttp_server_router_middleware.go index 99fb2acaf..74a3d483a 100644 --- a/net/ghttp/ghttp_server_router_middleware.go +++ b/net/ghttp/ghttp_server_router_middleware.go @@ -8,8 +8,9 @@ package ghttp import ( "context" - "github.com/gogf/gf/v2/debug/gdebug" "reflect" + + "github.com/gogf/gf/v2/debug/gdebug" ) const ( diff --git a/net/ghttp/ghttp_server_router_serve.go b/net/ghttp/ghttp_server_router_serve.go index baa5302ca..5083c2fb4 100644 --- a/net/ghttp/ghttp_server_router_serve.go +++ b/net/ghttp/ghttp_server_router_serve.go @@ -8,13 +8,13 @@ package ghttp import ( "fmt" + "strings" + + "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/internal/json" - "strings" - - "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/text/gregex" ) diff --git a/net/ghttp/ghttp_server_service_handler.go b/net/ghttp/ghttp_server_service_handler.go index 281f3a45c..57b675396 100644 --- a/net/ghttp/ghttp_server_service_handler.go +++ b/net/ghttp/ghttp_server_service_handler.go @@ -9,12 +9,12 @@ package ghttp import ( "bytes" "context" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "reflect" "strings" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/text/gstr" ) diff --git a/net/ghttp/ghttp_server_swagger.go b/net/ghttp/ghttp_server_swagger.go index e56ddca75..ea0cd34fc 100644 --- a/net/ghttp/ghttp_server_swagger.go +++ b/net/ghttp/ghttp_server_swagger.go @@ -7,9 +7,10 @@ package ghttp import ( + "net/http" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gstr" - "net/http" ) const ( diff --git a/net/ghttp/ghttp_server_websocket.go b/net/ghttp/ghttp_server_websocket.go index 65c8740ec..2dbde255e 100644 --- a/net/ghttp/ghttp_server_websocket.go +++ b/net/ghttp/ghttp_server_websocket.go @@ -15,23 +15,23 @@ type WebSocket struct { } const ( - // TextMessage denotes a text data message. The text message payload is + // WsMsgText TextMessage denotes a text data message. The text message payload is // interpreted as UTF-8 encoded text data. - WS_MSG_TEXT = websocket.TextMessage + WsMsgText = websocket.TextMessage - // BinaryMessage denotes a binary data message. - WS_MSG_BINARY = websocket.BinaryMessage + // WsMsgBinary BinaryMessage denotes a binary data message. + WsMsgBinary = websocket.BinaryMessage - // CloseMessage denotes a close control message. The optional message + // WsMsgClose CloseMessage denotes a close control message. The optional message // payload contains a numeric code and text. Use the FormatCloseMessage // function to format a close message payload. - WS_MSG_CLOSE = websocket.CloseMessage + WsMsgClose = websocket.CloseMessage - // PingMessage denotes a ping control message. The optional message payload + // WsMsgPing PingMessage denotes a ping control message. The optional message payload // is UTF-8 encoded text. - WS_MSG_PING = websocket.PingMessage + WsMsgPing = websocket.PingMessage - // PongMessage denotes a pong control message. The optional message payload + // WsMsgPong PongMessage denotes a pong control message. The optional message payload // is UTF-8 encoded text. - WS_MSG_PONG = websocket.PongMessage + WsMsgPong = websocket.PongMessage ) diff --git a/net/ghttp/ghttp_unit_client_test.go b/net/ghttp/ghttp_unit_client_test.go index 42dc62b66..e69b08955 100644 --- a/net/ghttp/ghttp_unit_client_test.go +++ b/net/ghttp/ghttp_unit_client_test.go @@ -17,12 +17,11 @@ import ( "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/util/guid" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/guid" ) func Test_Client_Basic(t *testing.T) { diff --git a/net/ghttp/ghttp_unit_config_test.go b/net/ghttp/ghttp_unit_config_test.go index 337638d0c..86dbf0a1c 100644 --- a/net/ghttp/ghttp_unit_config_test.go +++ b/net/ghttp/ghttp_unit_config_test.go @@ -8,18 +8,16 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/text/gstr" "testing" "time" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" - + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" ) func Test_ConfigFromMap(t *testing.T) { @@ -47,7 +45,7 @@ func Test_SetConfigWithMap(t *testing.T) { gtest.C(t, func(t *gtest.T) { m := g.Map{ "Address": ":8199", - //"ServerRoot": "/var/www/MyServerRoot", + // "ServerRoot": "/var/www/MyServerRoot", "IndexFiles": g.Slice{"index.php", "main.php"}, "AccessLogEnabled": true, "ErrorLogEnabled": true, diff --git a/net/ghttp/ghttp_unit_error_code_test.go b/net/ghttp/ghttp_unit_error_code_test.go index c59d14b25..c52dec18f 100644 --- a/net/ghttp/ghttp_unit_error_code_test.go +++ b/net/ghttp/ghttp_unit_error_code_test.go @@ -10,13 +10,13 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/net/ghttp" "testing" "time" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/net/ghttp/ghttp_unit_https_test.go b/net/ghttp/ghttp_unit_https_test.go index c8bed6c3f..26e7d70d8 100644 --- a/net/ghttp/ghttp_unit_https_test.go +++ b/net/ghttp/ghttp_unit_https_test.go @@ -8,18 +8,17 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/text/gstr" "testing" "time" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/test/gtest" - _ "github.com/gogf/gf/v2/net/ghttp/testdata/https/packed" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" ) func Test_HTTPS_Basic(t *testing.T) { diff --git a/net/ghttp/ghttp_unit_init_test.go b/net/ghttp/ghttp_unit_init_test.go index 71f5b63d9..65a6855c4 100644 --- a/net/ghttp/ghttp_unit_init_test.go +++ b/net/ghttp/ghttp_unit_init_test.go @@ -8,6 +8,7 @@ package ghttp_test import ( "context" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/os/genv" ) diff --git a/net/ghttp/ghttp_unit_log_test.go b/net/ghttp/ghttp_unit_log_test.go index 76e11159c..5c1f99809 100644 --- a/net/ghttp/ghttp_unit_log_test.go +++ b/net/ghttp/ghttp_unit_log_test.go @@ -10,15 +10,15 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/text/gstr" "testing" "time" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" ) func Test_Log(t *testing.T) { @@ -52,11 +52,11 @@ func Test_Log(t *testing.T) { t.Assert(gstr.Contains(gfile.GetContents(logPath1), "HANDLER"), true) logPath2 := gfile.Join(logDir, "access-"+gtime.Now().Format("Ymd")+".log") - //fmt.Println(gfile.GetContents(logPath2)) + // fmt.Println(gfile.GetContents(logPath2)) t.Assert(gstr.Contains(gfile.GetContents(logPath2), " /hello "), true) logPath3 := gfile.Join(logDir, "error-"+gtime.Now().Format("Ymd")+".log") - //fmt.Println(gfile.GetContents(logPath3)) + // fmt.Println(gfile.GetContents(logPath3)) t.Assert(gstr.Contains(gfile.GetContents(logPath3), "custom error"), true) }) } diff --git a/net/ghttp/ghttp_unit_middleware_basic_test.go b/net/ghttp/ghttp_unit_middleware_basic_test.go index f831e997c..2837abb35 100644 --- a/net/ghttp/ghttp_unit_middleware_basic_test.go +++ b/net/ghttp/ghttp_unit_middleware_basic_test.go @@ -8,12 +8,12 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/debug/gdebug" "net/http" "testing" "time" + "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" diff --git a/net/ghttp/ghttp_unit_middleware_cors_test.go b/net/ghttp/ghttp_unit_middleware_cors_test.go index b7d09c179..27f68c4c2 100644 --- a/net/ghttp/ghttp_unit_middleware_cors_test.go +++ b/net/ghttp/ghttp_unit_middleware_cors_test.go @@ -8,11 +8,12 @@ package ghttp_test import ( "fmt" + "testing" + "time" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" - "testing" - "time" ) func Test_Middleware_CORS1(t *testing.T) { diff --git a/net/ghttp/ghttp_unit_openapi_swagger_test.go b/net/ghttp/ghttp_unit_openapi_swagger_test.go index d8d0b814d..14919ef0c 100644 --- a/net/ghttp/ghttp_unit_openapi_swagger_test.go +++ b/net/ghttp/ghttp_unit_openapi_swagger_test.go @@ -9,15 +9,15 @@ package ghttp_test import ( "context" "fmt" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/util/gmeta" "testing" "time" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gmeta" ) func Test_OpenApi_Swagger(t *testing.T) { diff --git a/net/ghttp/ghttp_unit_request_ctx_test.go b/net/ghttp/ghttp_unit_request_ctx_test.go index 55758f010..0cd9c3303 100644 --- a/net/ghttp/ghttp_unit_request_ctx_test.go +++ b/net/ghttp/ghttp_unit_request_ctx_test.go @@ -9,11 +9,12 @@ package ghttp_test import ( "context" "fmt" + "testing" + "time" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" - "testing" - "time" ) func Test_Request_SetCtx(t *testing.T) { diff --git a/net/ghttp/ghttp_unit_request_file_test.go b/net/ghttp/ghttp_unit_request_file_test.go index aeb237250..8a3a87ac0 100644 --- a/net/ghttp/ghttp_unit_request_file_test.go +++ b/net/ghttp/ghttp_unit_request_file_test.go @@ -8,16 +8,16 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/text/gstr" "testing" "time" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" ) func Test_Params_File_Single(t *testing.T) { diff --git a/net/ghttp/ghttp_unit_request_json_test.go b/net/ghttp/ghttp_unit_request_json_test.go index 75a829c81..b3324b7e4 100644 --- a/net/ghttp/ghttp_unit_request_json_test.go +++ b/net/ghttp/ghttp_unit_request_json_test.go @@ -8,11 +8,11 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/internal/json" "testing" "time" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/net/ghttp/ghttp_unit_request_struct_test.go b/net/ghttp/ghttp_unit_request_struct_test.go index 6ef404f86..1f748906b 100644 --- a/net/ghttp/ghttp_unit_request_struct_test.go +++ b/net/ghttp/ghttp_unit_request_struct_test.go @@ -11,11 +11,10 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/util/gvalid" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gvalid" ) func Test_Params_Parse(t *testing.T) { @@ -359,7 +358,7 @@ func Test_Params_Parse_Attr_Pointer2(t *testing.T) { } // It does not support this kind of converting yet. -//func Test_Params_Parse_Attr_SliceSlice(t *testing.T) { +// func Test_Params_Parse_Attr_SliceSlice(t *testing.T) { // type User struct { // Id int // Name string @@ -387,7 +386,7 @@ func Test_Params_Parse_Attr_Pointer2(t *testing.T) { // client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p)) // t.Assert(client.PostContent(ctx, "/parse", `{"id":1,"name":"john","scores":[[1,2,3]]}`), `1100`) // }) -//} +// } func Test_Params_Struct(t *testing.T) { type User struct { diff --git a/net/ghttp/ghttp_unit_request_test.go b/net/ghttp/ghttp_unit_request_test.go index 92a3df736..c40f2ff16 100644 --- a/net/ghttp/ghttp_unit_request_test.go +++ b/net/ghttp/ghttp_unit_request_test.go @@ -14,7 +14,6 @@ import ( "time" "github.com/gogf/gf/v2/encoding/gjson" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" diff --git a/net/ghttp/ghttp_unit_router_domain_basic_test.go b/net/ghttp/ghttp_unit_router_domain_basic_test.go index 1c589cc22..9ad152ebf 100644 --- a/net/ghttp/ghttp_unit_router_domain_basic_test.go +++ b/net/ghttp/ghttp_unit_router_domain_basic_test.go @@ -8,11 +8,11 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/internal/intlog" "testing" "time" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/net/ghttp/ghttp_unit_router_handler_extended_test.go b/net/ghttp/ghttp_unit_router_handler_extended_test.go index 0b0c3c937..8d5a15e58 100644 --- a/net/ghttp/ghttp_unit_router_handler_extended_test.go +++ b/net/ghttp/ghttp_unit_router_handler_extended_test.go @@ -9,10 +9,10 @@ package ghttp_test import ( "context" "fmt" - "github.com/gogf/gf/v2/errors/gerror" "testing" "time" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" diff --git a/net/ghttp/ghttp_unit_static_test.go b/net/ghttp/ghttp_unit_static_test.go index a19e46570..9c65534e5 100644 --- a/net/ghttp/ghttp_unit_static_test.go +++ b/net/ghttp/ghttp_unit_static_test.go @@ -10,15 +10,14 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/debug/gdebug" "testing" "time" - "github.com/gogf/gf/v2/text/gstr" - + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" ) func Test_Static_ServerRoot(t *testing.T) { diff --git a/net/ghttp/ghttp_unit_template_test.go b/net/ghttp/ghttp_unit_template_test.go index 845ec53db..bfb077585 100644 --- a/net/ghttp/ghttp_unit_template_test.go +++ b/net/ghttp/ghttp_unit_template_test.go @@ -10,14 +10,14 @@ package ghttp_test import ( "fmt" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/encoding/ghtml" - "github.com/gogf/gf/v2/os/gview" "testing" "time" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/encoding/ghtml" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/net/ghttp/ghttp_unit_websocket_client_test.go b/net/ghttp/ghttp_unit_websocket_client_test.go index 3b831e272..56c2c794d 100644 --- a/net/ghttp/ghttp_unit_websocket_client_test.go +++ b/net/ghttp/ghttp_unit_websocket_client_test.go @@ -12,11 +12,10 @@ import ( "testing" "time" - "github.com/gorilla/websocket" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" + "github.com/gorilla/websocket" ) func Test_WebSocketClient(t *testing.T) { diff --git a/net/ghttp/ghttp_unit_websocket_test.go b/net/ghttp/ghttp_unit_websocket_test.go index 098bc7044..f03fc17bf 100644 --- a/net/ghttp/ghttp_unit_websocket_test.go +++ b/net/ghttp/ghttp_unit_websocket_test.go @@ -11,11 +11,10 @@ import ( "testing" "time" - "github.com/gorilla/websocket" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" + "github.com/gorilla/websocket" ) func Test_WebSocket(t *testing.T) { diff --git a/net/ghttp/ghttp_z_example_init_test.go b/net/ghttp/ghttp_z_example_init_test.go index e640202d8..6bc446825 100644 --- a/net/ghttp/ghttp_z_example_init_test.go +++ b/net/ghttp/ghttp_z_example_init_test.go @@ -7,9 +7,10 @@ package ghttp_test import ( + "time" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" - "time" ) func init() { diff --git a/net/ghttp/ghttp_z_example_post_test.go b/net/ghttp/ghttp_z_example_post_test.go index 58c4c6d70..6c573645d 100644 --- a/net/ghttp/ghttp_z_example_post_test.go +++ b/net/ghttp/ghttp_z_example_post_test.go @@ -8,6 +8,7 @@ package ghttp_test import ( "fmt" + "github.com/gogf/gf/v2/frame/g" ) diff --git a/net/ghttp/ghttp_z_example_test.go b/net/ghttp/ghttp_z_example_test.go index 81d96cc49..61aeba006 100644 --- a/net/ghttp/ghttp_z_example_test.go +++ b/net/ghttp/ghttp_z_example_test.go @@ -9,10 +9,11 @@ package ghttp_test import ( "context" "fmt" + "time" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gfile" - "time" ) func ExampleHelloWorld() { diff --git a/net/ghttp/internal/client/client.go b/net/ghttp/internal/client/client.go index a6c1686d8..c685b0f6a 100644 --- a/net/ghttp/internal/client/client.go +++ b/net/ghttp/internal/client/client.go @@ -11,12 +11,6 @@ import ( "crypto/rand" "crypto/tls" "fmt" - "github.com/gogf/gf/v2" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/text/gstr" - "golang.org/x/net/proxy" "net" "net/http" "net/http/cookiejar" @@ -24,6 +18,13 @@ import ( "strings" "time" + "github.com/gogf/gf/v2" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/text/gstr" + "golang.org/x/net/proxy" + "github.com/gogf/gf/v2/text/gregex" ) @@ -232,7 +233,7 @@ func (c *Client) SetProxy(proxyURL string) { return dialer.Dial(network, addr) } } - //c.SetTimeout(10*time.Second) + // c.SetTimeout(10*time.Second) } } diff --git a/net/ghttp/internal/client/client_bytes.go b/net/ghttp/internal/client/client_bytes.go index b6450d662..5cfb5bd17 100644 --- a/net/ghttp/internal/client/client_bytes.go +++ b/net/ghttp/internal/client/client_bytes.go @@ -8,6 +8,7 @@ package client import ( "context" + "github.com/gogf/gf/v2/internal/intlog" ) diff --git a/net/ghttp/internal/client/client_dump.go b/net/ghttp/internal/client/client_dump.go index 1c970f19b..110f3db1d 100644 --- a/net/ghttp/internal/client/client_dump.go +++ b/net/ghttp/internal/client/client_dump.go @@ -8,10 +8,11 @@ package client import ( "fmt" - "github.com/gogf/gf/v2/internal/utils" "io/ioutil" "net/http" "net/http/httputil" + + "github.com/gogf/gf/v2/internal/utils" ) // dumpTextFormat is the format of the dumped raw string diff --git a/net/ghttp/internal/client/client_request.go b/net/ghttp/internal/client/client_request.go index 3bc27a60c..c3486ba84 100644 --- a/net/ghttp/internal/client/client_request.go +++ b/net/ghttp/internal/client/client_request.go @@ -9,13 +9,6 @@ package client import ( "bytes" "context" - "github.com/gogf/gf/v2/encoding/gjson" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/utils" - "github.com/gogf/gf/v2/net/ghttp/internal/httputil" "io" "io/ioutil" "mime/multipart" @@ -24,11 +17,17 @@ import ( "strings" "time" + "github.com/gogf/gf/v2/encoding/gjson" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/utils" + "github.com/gogf/gf/v2/net/ghttp/internal/httputil" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" - - "github.com/gogf/gf/v2/os/gfile" ) // Get send GET request and returns the response object. @@ -310,7 +309,7 @@ func (c *Client) callRequest(req *http.Request) (resp *Response, err error) { c.retryCount-- time.Sleep(c.retryInterval) } else { - //return resp, err + // return resp, err break } } else { diff --git a/net/ghttp/internal/client/client_var.go b/net/ghttp/internal/client/client_var.go index a959e0818..2a9a1cac2 100644 --- a/net/ghttp/internal/client/client_var.go +++ b/net/ghttp/internal/client/client_var.go @@ -8,6 +8,7 @@ package client import ( "context" + "github.com/gogf/gf/v2/container/gvar" ) diff --git a/net/ghttp/internal/httputil/httputils.go b/net/ghttp/internal/httputil/httputils.go index 84c0679c4..7149938b9 100644 --- a/net/ghttp/internal/httputil/httputils.go +++ b/net/ghttp/internal/httputil/httputils.go @@ -7,11 +7,11 @@ package httputil import ( - "github.com/gogf/gf/v2/text/gstr" "net/http" "strings" "github.com/gogf/gf/v2/encoding/gurl" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/net/gipv4/gipv4_ip.go b/net/gipv4/gipv4_ip.go index ef47e90a8..fe977a9e7 100644 --- a/net/gipv4/gipv4_ip.go +++ b/net/gipv4/gipv4_ip.go @@ -8,11 +8,12 @@ package gipv4 import ( - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "net" "strconv" "strings" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" ) // GetIpArray retrieves and returns all the ip of current host. diff --git a/net/gipv6/gipv6.go b/net/gipv6/gipv6.go index 5b99917f9..146307c38 100644 --- a/net/gipv6/gipv6.go +++ b/net/gipv6/gipv6.go @@ -4,7 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. -// Package gipv4 provides useful API for IPv6 address handling. +// Package gipv6 provides useful API for IPv6 address handling. package gipv6 import "github.com/gogf/gf/v2/text/gregex" diff --git a/net/gsmtp/gsmtp.go b/net/gsmtp/gsmtp.go index eeb06aa0b..d7c437536 100644 --- a/net/gsmtp/gsmtp.go +++ b/net/gsmtp/gsmtp.go @@ -14,10 +14,11 @@ package gsmtp import ( "encoding/base64" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "net/smtp" "strings" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" ) // SMTP is the structure for smtp connection. diff --git a/net/gtcp/gtcp_conn_pkg.go b/net/gtcp/gtcp_conn_pkg.go index 4e1361904..c39b7d636 100644 --- a/net/gtcp/gtcp_conn_pkg.go +++ b/net/gtcp/gtcp_conn_pkg.go @@ -8,9 +8,10 @@ package gtcp import ( "encoding/binary" + "time" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "time" ) const ( diff --git a/net/gtcp/gtcp_server.go b/net/gtcp/gtcp_server.go index 1b6b180a5..33b686dbd 100644 --- a/net/gtcp/gtcp_server.go +++ b/net/gtcp/gtcp_server.go @@ -9,11 +9,12 @@ package gtcp import ( "context" "crypto/tls" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "net" "sync" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/util/gconv" diff --git a/net/gtrace/gtrace.go b/net/gtrace/gtrace.go index d88c27145..f64bc621b 100644 --- a/net/gtrace/gtrace.go +++ b/net/gtrace/gtrace.go @@ -34,7 +34,7 @@ var ( intranetIpStr = strings.Join(intranetIps, ",") hostname, _ = os.Hostname() tracingInternal = true // tracingInternal enables tracing for internal type spans. - tracingMaxContentLogSize = 256 * 1024 // Max log size for request and response body, especially for HTTP/RPC request. + tracingMaxContentLogSize = 512 * 1024 // Max log size for request and response body, especially for HTTP/RPC request. // defaultTextMapPropagator is the default propagator for context propagation between peers. defaultTextMapPropagator = propagation.NewCompositeTextMapPropagator( propagation.TraceContext{}, @@ -71,7 +71,7 @@ func CommonLabels() []attribute.KeyValue { // IsActivated checks and returns if tracing feature is activated. func IsActivated(ctx context.Context) bool { - return GetTraceId(ctx) != "" + return GetTraceID(ctx) != "" } // CheckSetDefaultTextMapPropagator sets the default TextMapPropagator if it is not set previously. @@ -87,28 +87,28 @@ func GetDefaultTextMapPropagator() propagation.TextMapPropagator { return defaultTextMapPropagator } -// GetTraceId retrieves and returns TraceId from context. +// GetTraceID retrieves and returns TraceId from context. // It returns an empty string is tracing feature is not activated. -func GetTraceId(ctx context.Context) string { +func GetTraceID(ctx context.Context) string { if ctx == nil { return "" } - traceId := trace.SpanContextFromContext(ctx).TraceID() - if traceId.IsValid() { - return traceId.String() + traceID := trace.SpanContextFromContext(ctx).TraceID() + if traceID.IsValid() { + return traceID.String() } return "" } -// GetSpanId retrieves and returns SpanId from context. +// GetSpanID retrieves and returns SpanId from context. // It returns an empty string is tracing feature is not activated. -func GetSpanId(ctx context.Context) string { +func GetSpanID(ctx context.Context) string { if ctx == nil { return "" } - spanId := trace.SpanContextFromContext(ctx).SpanID() - if spanId.IsValid() { - return spanId.String() + spanID := trace.SpanContextFromContext(ctx).SpanID() + if spanID.IsValid() { + return spanID.String() } return "" } diff --git a/net/gudp/gudp_server.go b/net/gudp/gudp_server.go index 32908db14..fa9c0d43f 100644 --- a/net/gudp/gudp_server.go +++ b/net/gudp/gudp_server.go @@ -8,9 +8,10 @@ package gudp import ( "context" + "net" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "net" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/os/glog" diff --git a/net/gudp/gudp_unit_basic_test.go b/net/gudp/gudp_unit_basic_test.go index 8bff7874c..f611bb6ab 100644 --- a/net/gudp/gudp_unit_basic_test.go +++ b/net/gudp/gudp_unit_basic_test.go @@ -9,12 +9,13 @@ package gudp_test import ( "context" "fmt" + "testing" + "time" + "github.com/gogf/gf/v2/net/gudp" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" - "testing" - "time" ) func Test_Basic(t *testing.T) { diff --git a/os/gcache/gcache.go b/os/gcache/gcache.go index 8a1c6a3d3..02b8c15f5 100644 --- a/os/gcache/gcache.go +++ b/os/gcache/gcache.go @@ -11,8 +11,9 @@ package gcache import ( "context" - "github.com/gogf/gf/v2/container/gvar" "time" + + "github.com/gogf/gf/v2/container/gvar" ) // Default cache object. diff --git a/os/gcache/gcache_adapter.go b/os/gcache/gcache_adapter.go index c1bc7b452..0921e9101 100644 --- a/os/gcache/gcache_adapter.go +++ b/os/gcache/gcache_adapter.go @@ -8,8 +8,9 @@ package gcache import ( "context" - "github.com/gogf/gf/v2/container/gvar" "time" + + "github.com/gogf/gf/v2/container/gvar" ) // Adapter is the core adapter for cache features implements. diff --git a/os/gcache/gcache_adapter_memory.go b/os/gcache/gcache_adapter_memory.go index 767db7baf..5d1a40d29 100644 --- a/os/gcache/gcache_adapter_memory.go +++ b/os/gcache/gcache_adapter_memory.go @@ -8,13 +8,13 @@ package gcache import ( "context" - "github.com/gogf/gf/v2/container/gvar" "math" "time" "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtimer" ) diff --git a/os/gcache/gcache_adapter_memory_data.go b/os/gcache/gcache_adapter_memory_data.go index ecacaf55c..86af48724 100644 --- a/os/gcache/gcache_adapter_memory_data.go +++ b/os/gcache/gcache_adapter_memory_data.go @@ -7,9 +7,10 @@ package gcache import ( - "github.com/gogf/gf/v2/os/gtime" "sync" "time" + + "github.com/gogf/gf/v2/os/gtime" ) type adapterMemoryData struct { diff --git a/os/gcache/gcache_adapter_memory_expire_sets.go b/os/gcache/gcache_adapter_memory_expire_sets.go index fae11606b..b49678c7c 100644 --- a/os/gcache/gcache_adapter_memory_expire_sets.go +++ b/os/gcache/gcache_adapter_memory_expire_sets.go @@ -7,8 +7,9 @@ package gcache import ( - "github.com/gogf/gf/v2/container/gset" "sync" + + "github.com/gogf/gf/v2/container/gset" ) type adapterMemoryExpireSets struct { diff --git a/os/gcache/gcache_adapter_memory_item.go b/os/gcache/gcache_adapter_memory_item.go index b8c4ee993..5a7862cae 100644 --- a/os/gcache/gcache_adapter_memory_item.go +++ b/os/gcache/gcache_adapter_memory_item.go @@ -14,8 +14,6 @@ import ( func (item *adapterMemoryItem) IsExpired() bool { // Note that it should use greater than or equal judgement here // imagining that the cache time is only 1 millisecond. - if item.e >= gtime.TimestampMilli() { - return false - } - return true + + return item.e < gtime.TimestampMilli() } diff --git a/os/gcache/gcache_adapter_memory_lru.go b/os/gcache/gcache_adapter_memory_lru.go index 6fe91f5ba..cf478996c 100644 --- a/os/gcache/gcache_adapter_memory_lru.go +++ b/os/gcache/gcache_adapter_memory_lru.go @@ -72,12 +72,12 @@ func (lru *adapterMemoryLru) Pop() interface{} { } // Print is used for test only. -//func (lru *adapterMemoryLru) Print() { +// func (lru *adapterMemoryLru) Print() { // for _, v := range lru.list.FrontAll() { // fmt.Printf("%v ", v) // } // fmt.Println() -//} +// } // SyncAndClear synchronizes the keys from `rawList` to `list` and `data` // using Least Recently Used algorithm. diff --git a/os/gcache/gcache_cache.go b/os/gcache/gcache_cache.go index 69221a5a9..b01e53870 100644 --- a/os/gcache/gcache_cache.go +++ b/os/gcache/gcache_cache.go @@ -8,9 +8,10 @@ package gcache import ( "context" + "time" + "github.com/gogf/gf/v2/os/gtimer" "github.com/gogf/gf/v2/util/gconv" - "time" ) // Cache struct. diff --git a/os/gcache/gcache_cache_must.go b/os/gcache/gcache_cache_must.go index 3b9eb0f32..ddb7946df 100644 --- a/os/gcache/gcache_cache_must.go +++ b/os/gcache/gcache_cache_must.go @@ -8,8 +8,9 @@ package gcache import ( "context" - "github.com/gogf/gf/v2/container/gvar" "time" + + "github.com/gogf/gf/v2/container/gvar" ) // MustGet acts like Get, but it panics if any error occurs. diff --git a/os/gcache/gcache_z_example_cache_test.go b/os/gcache/gcache_z_example_cache_test.go index 8b783c153..96b96e3f3 100644 --- a/os/gcache/gcache_z_example_cache_test.go +++ b/os/gcache/gcache_z_example_cache_test.go @@ -2,9 +2,10 @@ package gcache_test import ( "fmt" + "time" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcache" - "time" ) func ExampleNew() { diff --git a/os/gcache/gcache_z_unit_basic_test.go b/os/gcache/gcache_z_unit_basic_test.go index 59ce23a0e..648b2e943 100644 --- a/os/gcache/gcache_z_unit_basic_test.go +++ b/os/gcache/gcache_z_unit_basic_test.go @@ -10,7 +10,6 @@ package gcache_test import ( "context" - "github.com/gogf/gf/v2/util/guid" "math" "testing" "time" @@ -20,6 +19,7 @@ import ( "github.com/gogf/gf/v2/os/gcache" "github.com/gogf/gf/v2/os/grpool" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/guid" ) var ( @@ -458,7 +458,7 @@ func TestCache_SetConcurrency(t *testing.T) { }() select { case <-time.After(2 * time.Second): - //t.Log("first part end") + // t.Log("first part end") } go func() { @@ -470,7 +470,7 @@ func TestCache_SetConcurrency(t *testing.T) { }() select { case <-time.After(2 * time.Second): - //t.Log("second part end") + // t.Log("second part end") } }) } diff --git a/os/gcfg/gcfg.go b/os/gcfg/gcfg.go index 81259c6b6..df038492a 100644 --- a/os/gcfg/gcfg.go +++ b/os/gcfg/gcfg.go @@ -10,6 +10,7 @@ package gcfg import ( "context" "fmt" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/intlog" diff --git a/os/gcfg/gcfg_adapter_file.go b/os/gcfg/gcfg_adapter_file.go index 094a1a10b..f2a15f2ae 100644 --- a/os/gcfg/gcfg_adapter_file.go +++ b/os/gcfg/gcfg_adapter_file.go @@ -8,6 +8,7 @@ package gcfg import ( "context" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gvar" diff --git a/os/gcfg/gcfg_adapter_file_content.go b/os/gcfg/gcfg_adapter_file_content.go index 7719b868f..f72f7ff09 100644 --- a/os/gcfg/gcfg_adapter_file_content.go +++ b/os/gcfg/gcfg_adapter_file_content.go @@ -8,6 +8,7 @@ package gcfg import ( "context" + "github.com/gogf/gf/v2/internal/intlog" ) diff --git a/os/gcfg/gcfg_adapter_file_path.go b/os/gcfg/gcfg_adapter_file_path.go index 6eb4f6dc2..c826ed13c 100644 --- a/os/gcfg/gcfg_adapter_file_path.go +++ b/os/gcfg/gcfg_adapter_file_path.go @@ -10,6 +10,7 @@ import ( "bytes" "context" "fmt" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" diff --git a/os/gcfg/gcfg_z_unit_adapter_file_test.go b/os/gcfg/gcfg_z_unit_adapter_file_test.go index e2f8a44d0..c0036a9f0 100644 --- a/os/gcfg/gcfg_z_unit_adapter_file_test.go +++ b/os/gcfg/gcfg_z_unit_adapter_file_test.go @@ -9,9 +9,10 @@ package gcfg_test import ( + "testing" + "github.com/gogf/gf/v2/os/gcfg" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func TestAdapterFile_SetPath(t *testing.T) { diff --git a/os/gcfg/gcfg_z_unit_basic_test.go b/os/gcfg/gcfg_z_unit_basic_test.go index 118ab5bcd..50090421c 100644 --- a/os/gcfg/gcfg_z_unit_basic_test.go +++ b/os/gcfg/gcfg_z_unit_basic_test.go @@ -9,14 +9,13 @@ package gcfg_test import ( - "github.com/gogf/gf/v2/os/gcmd" - "github.com/gogf/gf/v2/os/genv" "testing" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/os/gcfg" + "github.com/gogf/gf/v2/os/gcmd" + "github.com/gogf/gf/v2/os/genv" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gcfg/gcfg_z_unit_instance_test.go b/os/gcfg/gcfg_z_unit_instance_test.go index 81a8c6389..2e7f0dc42 100644 --- a/os/gcfg/gcfg_z_unit_instance_test.go +++ b/os/gcfg/gcfg_z_unit_instance_test.go @@ -10,12 +10,13 @@ package gcfg import ( "context" + "testing" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/os/genv" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" - "testing" ) var ( diff --git a/os/gcmd/gcmd.go b/os/gcmd/gcmd.go index b84575d48..5c80d0f5f 100644 --- a/os/gcmd/gcmd.go +++ b/os/gcmd/gcmd.go @@ -9,10 +9,11 @@ package gcmd import ( + "os" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/command" "github.com/gogf/gf/v2/internal/utils" - "os" ) var ( diff --git a/os/gcmd/gcmd_parser.go b/os/gcmd/gcmd_parser.go index 68d86fb74..9306be1b9 100644 --- a/os/gcmd/gcmd_parser.go +++ b/os/gcmd/gcmd_parser.go @@ -8,17 +8,15 @@ package gcmd import ( - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/json" "os" "strings" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/container/gvar" - + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" ) // Parser for arguments. diff --git a/os/gcmd/gcmd_z_unit_default_test.go b/os/gcmd/gcmd_z_unit_default_test.go index b38978933..dc570e3c2 100644 --- a/os/gcmd/gcmd_z_unit_default_test.go +++ b/os/gcmd/gcmd_z_unit_default_test.go @@ -9,12 +9,11 @@ package gcmd_test import ( - "github.com/gogf/gf/v2/os/genv" "testing" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcmd" - + "github.com/gogf/gf/v2/os/genv" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gcmd/gcmd_z_unit_parser_test.go b/os/gcmd/gcmd_z_unit_parser_test.go index 445369d58..7e183542a 100644 --- a/os/gcmd/gcmd_z_unit_parser_test.go +++ b/os/gcmd/gcmd_z_unit_parser_test.go @@ -13,9 +13,7 @@ import ( "testing" "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/os/gcmd" - "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gcron/gcron.go b/os/gcron/gcron.go index ed53e0a8a..d1a7ad74e 100644 --- a/os/gcron/gcron.go +++ b/os/gcron/gcron.go @@ -9,9 +9,9 @@ package gcron import ( "context" - "github.com/gogf/gf/v2/os/glog" "time" + "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gtimer" ) diff --git a/os/gcron/gcron_entry.go b/os/gcron/gcron_entry.go index 79e13754f..20e371dac 100644 --- a/os/gcron/gcron_entry.go +++ b/os/gcron/gcron_entry.go @@ -8,13 +8,13 @@ package gcron import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "reflect" "runtime" "time" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/os/gtimer" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/os/gcron/gcron_schedule.go b/os/gcron/gcron_schedule.go index 5827071bd..71da89d95 100644 --- a/os/gcron/gcron_schedule.go +++ b/os/gcron/gcron_schedule.go @@ -7,13 +7,13 @@ package gcron import ( - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/os/gtime" "strconv" "strings" "time" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/text/gregex" ) diff --git a/os/gcron/gcron_unit_1_test.go b/os/gcron/gcron_unit_1_test.go index 7d666d092..42e4d7552 100644 --- a/os/gcron/gcron_unit_1_test.go +++ b/os/gcron/gcron_unit_1_test.go @@ -8,11 +8,11 @@ package gcron_test import ( "context" - "github.com/gogf/gf/v2/frame/g" "testing" "time" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcron" "github.com/gogf/gf/v2/test/gtest" ) @@ -52,7 +52,7 @@ func TestCron_Basic(t *testing.T) { gtest.C(t, func(t *gtest.T) { cron := gcron.New() cron.Add(ctx, "* * * * * *", func(ctx context.Context) {}, "add") - //fmt.Println("start", time.Now()) + // fmt.Println("start", time.Now()) cron.DelayAdd(ctx, time.Second, "* * * * * *", func(ctx context.Context) {}, "delay_add") t.Assert(cron.Size(), 1) time.Sleep(1200 * time.Millisecond) diff --git a/os/gcron/gcron_unit_2_test.go b/os/gcron/gcron_unit_2_test.go index ab05ef129..159197534 100644 --- a/os/gcron/gcron_unit_2_test.go +++ b/os/gcron/gcron_unit_2_test.go @@ -8,11 +8,11 @@ package gcron_test import ( "context" - "github.com/gogf/gf/v2/frame/g" "testing" "time" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcron" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gctx/gctx.go b/os/gctx/gctx.go index ccb2f23d7..c365d415c 100644 --- a/os/gctx/gctx.go +++ b/os/gctx/gctx.go @@ -9,6 +9,7 @@ package gctx import ( "context" + "github.com/gogf/gf/v2/util/guid" ) diff --git a/os/gctx/gctx_test.go b/os/gctx/gctx_test.go index 040fe71ca..e92d12939 100644 --- a/os/gctx/gctx_test.go +++ b/os/gctx/gctx_test.go @@ -8,11 +8,11 @@ package gctx_test import ( "context" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/text/gstr" "testing" + "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" ) func Test_New(t *testing.T) { diff --git a/os/genv/genv.go b/os/genv/genv.go index d423d1e0b..0cc9e57c3 100644 --- a/os/genv/genv.go +++ b/os/genv/genv.go @@ -8,11 +8,12 @@ package genv import ( + "os" + "strings" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/os/gcmd" - "os" - "strings" ) // All returns a copy of strings representing the environment, diff --git a/os/genv/genv_test.go b/os/genv/genv_test.go index 7c1eef85f..ccdc9e5b7 100644 --- a/os/genv/genv_test.go +++ b/os/genv/genv_test.go @@ -7,11 +7,11 @@ package genv_test import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gcmd" "os" "testing" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gcmd" "github.com/gogf/gf/v2/os/genv" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" diff --git a/os/gfile/gfile.go b/os/gfile/gfile.go index 3fc6e18b7..d635108c2 100644 --- a/os/gfile/gfile.go +++ b/os/gfile/gfile.go @@ -8,7 +8,6 @@ package gfile import ( - "github.com/gogf/gf/v2/text/gstr" "os" "os/exec" "path/filepath" @@ -16,6 +15,7 @@ import ( "time" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/os/gfile/gfile_cache.go b/os/gfile/gfile_cache.go index 340831b79..2ed7854d8 100644 --- a/os/gfile/gfile_cache.go +++ b/os/gfile/gfile_cache.go @@ -8,11 +8,12 @@ package gfile import ( "context" + "time" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gcache" "github.com/gogf/gf/v2/os/gcmd" "github.com/gogf/gf/v2/os/gfsnotify" - "time" ) const ( diff --git a/os/gfile/gfile_copy.go b/os/gfile/gfile_copy.go index 9a241f937..eb94647f4 100644 --- a/os/gfile/gfile_copy.go +++ b/os/gfile/gfile_copy.go @@ -7,12 +7,13 @@ package gfile import ( - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "io" "io/ioutil" "os" "path/filepath" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" ) // Copy file/directory from `src` to `dst`. diff --git a/os/gfile/gfile_home.go b/os/gfile/gfile_home.go index a6137b156..f75de43fe 100644 --- a/os/gfile/gfile_home.go +++ b/os/gfile/gfile_home.go @@ -8,13 +8,14 @@ package gfile import ( "bytes" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "os" "os/exec" "os/user" "runtime" "strings" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" ) // Home returns absolute path of current user's home directory. diff --git a/os/gfile/gfile_scan.go b/os/gfile/gfile_scan.go index c3e244839..d5b02a370 100644 --- a/os/gfile/gfile_scan.go +++ b/os/gfile/gfile_scan.go @@ -7,12 +7,13 @@ package gfile import ( - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/text/gstr" "os" "path/filepath" "sort" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/text/gstr" ) const ( diff --git a/os/gfile/gfile_search.go b/os/gfile/gfile_search.go index a0ece5ed3..e344aa896 100644 --- a/os/gfile/gfile_search.go +++ b/os/gfile/gfile_search.go @@ -9,10 +9,10 @@ package gfile import ( "bytes" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" ) // Search searches file by name `name` in following paths with priority: diff --git a/os/gfile/gfile_source.go b/os/gfile/gfile_source.go index 2c7c78a56..4f9726633 100644 --- a/os/gfile/gfile_source.go +++ b/os/gfile/gfile_source.go @@ -7,12 +7,12 @@ package gfile import ( - "github.com/gogf/gf/v2/text/gstr" "os" "runtime" "strings" "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" ) var ( diff --git a/os/gfile/gfile_z_cache_test.go b/os/gfile/gfile_z_cache_test.go index 22ddec7b6..77e0099e4 100644 --- a/os/gfile/gfile_z_cache_test.go +++ b/os/gfile/gfile_z_cache_test.go @@ -7,12 +7,13 @@ package gfile_test import ( - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/test/gtest" "io/ioutil" "os" "testing" "time" + + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/test/gtest" ) func Test_GetContentsWithCache(t *testing.T) { diff --git a/os/gfile/gfile_z_contents_test.go b/os/gfile/gfile_z_contents_test.go index 488cdfd22..e95f0c68f 100644 --- a/os/gfile/gfile_z_contents_test.go +++ b/os/gfile/gfile_z_contents_test.go @@ -13,10 +13,9 @@ import ( "strings" "testing" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" ) func createTestFile(filename, content string) error { diff --git a/os/gfile/gfile_z_copy_test.go b/os/gfile/gfile_z_copy_test.go index 3df4cd4b2..6a4ebdfdf 100644 --- a/os/gfile/gfile_z_copy_test.go +++ b/os/gfile/gfile_z_copy_test.go @@ -7,10 +7,11 @@ package gfile_test import ( + "testing" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func Test_Copy(t *testing.T) { diff --git a/os/gfile/gfile_z_readline_test.go b/os/gfile/gfile_z_readline_test.go index 82f1c273a..1cc860ebd 100644 --- a/os/gfile/gfile_z_readline_test.go +++ b/os/gfile/gfile_z_readline_test.go @@ -7,10 +7,10 @@ package gfile_test import ( - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/errors/gerror" "testing" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gfile/gfile_z_scan_test.go b/os/gfile/gfile_z_scan_test.go index e3da18f3f..c64ec62c0 100644 --- a/os/gfile/gfile_z_scan_test.go +++ b/os/gfile/gfile_z_scan_test.go @@ -7,12 +7,11 @@ package gfile_test import ( - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/debug/gdebug" "testing" + "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gfile/gfile_z_size_test.go b/os/gfile/gfile_z_size_test.go index 39d065ec1..f5f97c506 100644 --- a/os/gfile/gfile_z_size_test.go +++ b/os/gfile/gfile_z_size_test.go @@ -7,11 +7,11 @@ package gfile_test import ( - "github.com/gogf/gf/v2/util/gconv" "testing" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_Size(t *testing.T) { diff --git a/os/gfile/gfile_z_test.go b/os/gfile/gfile_z_test.go index fce200568..60d7bf7ba 100644 --- a/os/gfile/gfile_z_test.go +++ b/os/gfile/gfile_z_test.go @@ -12,11 +12,10 @@ import ( "strings" "testing" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_IsDir(t *testing.T) { @@ -399,7 +398,7 @@ func Test_Glob(t *testing.T) { testpath() + "/testfiles/t2.txt", } - //===============================构建测试文件 + // ===============================构建测试文件 createDir(dirpath) for _, v := range havelist1 { createTestFile(dirpath+"/"+v, "") diff --git a/os/gfpool/gfpool.go b/os/gfpool/gfpool.go index 98bf0e224..5eec01b27 100644 --- a/os/gfpool/gfpool.go +++ b/os/gfpool/gfpool.go @@ -8,14 +8,15 @@ package gfpool import ( + "os" + "time" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gpool" "github.com/gogf/gf/v2/container/gtype" - "os" - "time" ) -// File pointer pool. +// Pool pointer pool. type Pool struct { id *gtype.Int // Pool id, which is used to mark this pool whether recreated. pool *gpool.Pool // Underlying pool. diff --git a/os/gfpool/gfpool_file.go b/os/gfpool/gfpool_file.go index 3d318fd26..290615171 100644 --- a/os/gfpool/gfpool_file.go +++ b/os/gfpool/gfpool_file.go @@ -8,10 +8,11 @@ package gfpool import ( "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "os" "time" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" ) // Open creates and returns a file item with given file path, flag and opening permission. @@ -25,10 +26,10 @@ func Open(path string, flag int, perm os.FileMode, ttl ...time.Duration) (file * // DO NOT search the path here wasting performance! // Leave following codes just for warning you. // - //path, err = gfile.Search(path) - //if err != nil { + // path, err = gfile.Search(path) + // if err != nil { // return nil, err - //} + // } pool := pools.GetOrSetFuncLock( fmt.Sprintf("%s&%d&%d&%d", path, flag, fpTTL, perm), func() interface{} { diff --git a/os/gfpool/gfpool_z_unit_concurrent_test.go b/os/gfpool/gfpool_z_unit_concurrent_test.go index 9c934b809..646293e09 100644 --- a/os/gfpool/gfpool_z_unit_concurrent_test.go +++ b/os/gfpool/gfpool_z_unit_concurrent_test.go @@ -7,13 +7,14 @@ package gfpool_test import ( + "os" + "testing" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gfpool" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "os" - "testing" ) func Test_ConcurrentOS(t *testing.T) { @@ -97,7 +98,7 @@ func Test_ConcurrentOS(t *testing.T) { t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000) }) // DATA RACE - //gtest.C(t, func(t *gtest.T) { + // gtest.C(t, func(t *gtest.T) { // path := gfile.TempDir(gtime.TimestampNanoStr()) // defer gfile.Remove(path) // f1, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) @@ -131,7 +132,7 @@ func Test_ConcurrentOS(t *testing.T) { // close(ch) // wg.Wait() // t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000) - //}) + // }) } func Test_ConcurrentGFPool(t *testing.T) { @@ -157,7 +158,7 @@ func Test_ConcurrentGFPool(t *testing.T) { t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000) }) // DATA RACE - //gtest.C(t, func(t *gtest.T) { + // gtest.C(t, func(t *gtest.T) { // path := gfile.TempDir(gtime.TimestampNanoStr()) // defer gfile.Remove(path) // f1, err := gfpool.Open(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) @@ -191,5 +192,5 @@ func Test_ConcurrentGFPool(t *testing.T) { // close(ch) // wg.Wait() // t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000) - //}) + // }) } diff --git a/os/gfsnotify/gfsnotify.go b/os/gfsnotify/gfsnotify.go index beadd0d52..12235ae61 100644 --- a/os/gfsnotify/gfsnotify.go +++ b/os/gfsnotify/gfsnotify.go @@ -9,10 +9,6 @@ package gfsnotify import ( "context" - "github.com/gogf/gf/v2/container/gset" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" "sync" "time" @@ -20,7 +16,11 @@ import ( "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gqueue" + "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gcache" ) diff --git a/os/gfsnotify/gfsnotify_watcher.go b/os/gfsnotify/gfsnotify_watcher.go index 92bf2cf00..87aee12b4 100644 --- a/os/gfsnotify/gfsnotify_watcher.go +++ b/os/gfsnotify/gfsnotify_watcher.go @@ -8,11 +8,11 @@ package gfsnotify import ( "context" + + "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" - - "github.com/gogf/gf/v2/container/glist" ) // Add monitors `path` with callback function `callbackFunc` to the watcher. diff --git a/os/gfsnotify/gfsnotify_watcher_loop.go b/os/gfsnotify/gfsnotify_watcher_loop.go index bd41d3908..56c67e4be 100644 --- a/os/gfsnotify/gfsnotify_watcher_loop.go +++ b/os/gfsnotify/gfsnotify_watcher_loop.go @@ -8,6 +8,7 @@ package gfsnotify import ( "context" + "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/internal/intlog" ) diff --git a/os/gfsnotify/gfsnotify_z_unit_test.go b/os/gfsnotify/gfsnotify_z_unit_test.go index d8ec316c6..020e4fe09 100644 --- a/os/gfsnotify/gfsnotify_z_unit_test.go +++ b/os/gfsnotify/gfsnotify_z_unit_test.go @@ -7,10 +7,10 @@ package gfsnotify_test import ( - "github.com/gogf/gf/v2/container/garray" "testing" "time" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gfsnotify" @@ -204,7 +204,7 @@ func TestWatcher_WatchFolderWithoutRecursively(t *testing.T) { t.AssertNil(err) _, err = gfsnotify.Add(dirPath, func(event *gfsnotify.Event) { - //fmt.Println(event.String()) + // fmt.Println(event.String()) array.Append(1) }, false) t.AssertNil(err) diff --git a/os/glog/glog_logger.go b/os/glog/glog_logger.go index bdd873976..178c5828b 100644 --- a/os/glog/glog_logger.go +++ b/os/glog/glog_logger.go @@ -10,25 +10,24 @@ import ( "bytes" "context" "fmt" - "github.com/fatih/color" - "github.com/gogf/gf/v2/container/gtype" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gfpool" - "github.com/gogf/gf/v2/os/gmlock" - "github.com/gogf/gf/v2/os/gtimer" - "go.opentelemetry.io/otel/trace" "io" "os" "strings" "time" + "github.com/fatih/color" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/debug/gdebug" - + "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gfpool" + "github.com/gogf/gf/v2/os/gmlock" "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/os/gtimer" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/util/gconv" + "go.opentelemetry.io/otel/trace" ) // Logger is the struct for logging management. diff --git a/os/glog/glog_logger_config.go b/os/glog/glog_logger_config.go index c33ac786e..20c36e699 100644 --- a/os/glog/glog_logger_config.go +++ b/os/glog/glog_logger_config.go @@ -8,14 +8,14 @@ package glog import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/os/gctx" "io" "strings" "time" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gutil" @@ -255,7 +255,7 @@ func (l *Logger) SetHandlers(handlers ...Handler) { l.config.Handlers = handlers } -//SetWriterColorEnable sets the file logging with color +// SetWriterColorEnable sets the file logging with color func (l *Logger) SetWriterColorEnable(enabled bool) { l.config.WriterColorEnable = enabled } diff --git a/os/glog/glog_logger_level.go b/os/glog/glog_logger_level.go index 3f20e65d4..e1fe6b6a3 100644 --- a/os/glog/glog_logger_level.go +++ b/os/glog/glog_logger_level.go @@ -7,9 +7,10 @@ package glog import ( + "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "strings" ) // Note that the LEVEL_PANI and LEVEL_FATA levels are not used for logging output, diff --git a/os/glog/glog_logger_rotate.go b/os/glog/glog_logger_rotate.go index 19470606b..6e7ca96de 100644 --- a/os/glog/glog_logger_rotate.go +++ b/os/glog/glog_logger_rotate.go @@ -9,6 +9,8 @@ package glog import ( "context" "fmt" + "time" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/encoding/gcompress" "github.com/gogf/gf/v2/internal/intlog" @@ -17,7 +19,6 @@ import ( "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gtimer" "github.com/gogf/gf/v2/text/gregex" - "time" ) const ( diff --git a/os/glog/glog_z_example_test.go b/os/glog/glog_z_example_test.go index 3d8467b7d..e31c321c1 100644 --- a/os/glog/glog_z_example_test.go +++ b/os/glog/glog_z_example_test.go @@ -8,6 +8,7 @@ package glog_test import ( "context" + "github.com/gogf/gf/v2/frame/g" ) diff --git a/os/glog/glog_z_unit_basic_test.go b/os/glog/glog_z_unit_basic_test.go index 393953847..30ef4a4b7 100644 --- a/os/glog/glog_z_unit_basic_test.go +++ b/os/glog/glog_z_unit_basic_test.go @@ -9,9 +9,10 @@ package glog import ( "bytes" "context" + "testing" + "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" ) var ( diff --git a/os/glog/glog_z_unit_chaining_test.go b/os/glog/glog_z_unit_chaining_test.go index 846ce62ca..f0f6989e5 100644 --- a/os/glog/glog_z_unit_chaining_test.go +++ b/os/glog/glog_z_unit_chaining_test.go @@ -9,12 +9,13 @@ package glog import ( "bytes" "fmt" + "testing" + "time" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" - "time" ) func Test_To(t *testing.T) { diff --git a/os/glog/glog_z_unit_concurrent_test.go b/os/glog/glog_z_unit_concurrent_test.go index 43f036f68..a0d230dc1 100644 --- a/os/glog/glog_z_unit_concurrent_test.go +++ b/os/glog/glog_z_unit_concurrent_test.go @@ -7,13 +7,14 @@ package glog_test import ( + "sync" + "testing" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "sync" - "testing" ) func Test_Concurrent(t *testing.T) { diff --git a/os/glog/glog_z_unit_config_test.go b/os/glog/glog_z_unit_config_test.go index 43b2e1825..6b33466d9 100644 --- a/os/glog/glog_z_unit_config_test.go +++ b/os/glog/glog_z_unit_config_test.go @@ -8,9 +8,10 @@ package glog import ( "bytes" - "github.com/gogf/gf/v2/test/gtest" "strings" "testing" + + "github.com/gogf/gf/v2/test/gtest" ) func Test_SetConfigWithMap(t *testing.T) { diff --git a/os/glog/glog_z_unit_ctx_test.go b/os/glog/glog_z_unit_ctx_test.go index 028ed0a5b..a760cd331 100644 --- a/os/glog/glog_z_unit_ctx_test.go +++ b/os/glog/glog_z_unit_ctx_test.go @@ -9,12 +9,13 @@ package glog_test import ( "bytes" "context" + "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" ) func Test_Ctx(t *testing.T) { diff --git a/os/glog/glog_z_unit_handler_test.go b/os/glog/glog_z_unit_handler_test.go index 587614f92..aeca8983e 100644 --- a/os/glog/glog_z_unit_handler_test.go +++ b/os/glog/glog_z_unit_handler_test.go @@ -9,11 +9,12 @@ package glog_test import ( "bytes" "context" + "testing" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" ) var arrayForHandlerTest1 = garray.NewStrArray() diff --git a/os/glog/glog_z_unit_level_test.go b/os/glog/glog_z_unit_level_test.go index cb49574a0..c5c9b68aa 100644 --- a/os/glog/glog_z_unit_level_test.go +++ b/os/glog/glog_z_unit_level_test.go @@ -8,9 +8,10 @@ package glog import ( "bytes" + "testing" + "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" ) func Test_LevelPrefix(t *testing.T) { diff --git a/os/glog/glog_z_unit_rotate_test.go b/os/glog/glog_z_unit_rotate_test.go index 7ec5fe090..36da85b1d 100644 --- a/os/glog/glog_z_unit_rotate_test.go +++ b/os/glog/glog_z_unit_rotate_test.go @@ -9,14 +9,15 @@ package glog_test import ( "context" "fmt" + "testing" + "time" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" - "testing" - "time" ) var ( diff --git a/os/gmlock/gmlock_unit_rlock_test.go b/os/gmlock/gmlock_unit_rlock_test.go index 63d4bba2a..75cf0e5ba 100644 --- a/os/gmlock/gmlock_unit_rlock_test.go +++ b/os/gmlock/gmlock_unit_rlock_test.go @@ -16,7 +16,7 @@ import ( ) func Test_Locker_RLock(t *testing.T) { - //RLock before Lock + // RLock before Lock gtest.C(t, func(t *gtest.T) { key := "testRLockBeforeLock" array := garray.New(true) @@ -38,7 +38,7 @@ func Test_Locker_RLock(t *testing.T) { t.Assert(array.Len(), 2) }) - //Lock before RLock + // Lock before RLock gtest.C(t, func(t *gtest.T) { key := "testLockBeforeRLock" array := garray.New(true) @@ -60,7 +60,7 @@ func Test_Locker_RLock(t *testing.T) { t.Assert(array.Len(), 2) }) - //Lock before RLocks + // Lock before RLocks gtest.C(t, func(t *gtest.T) { key := "testLockBeforeRLocks" array := garray.New(true) @@ -92,7 +92,7 @@ func Test_Locker_RLock(t *testing.T) { } func Test_Locker_TryRLock(t *testing.T) { - //Lock before TryRLock + // Lock before TryRLock gtest.C(t, func(t *gtest.T) { key := "testLockBeforeTryRLock" array := garray.New(true) @@ -115,7 +115,7 @@ func Test_Locker_TryRLock(t *testing.T) { t.Assert(array.Len(), 1) }) - //Lock before TryRLocks + // Lock before TryRLocks gtest.C(t, func(t *gtest.T) { key := "testLockBeforeTryRLocks" array := garray.New(true) @@ -147,7 +147,7 @@ func Test_Locker_TryRLock(t *testing.T) { } func Test_Locker_RLockFunc(t *testing.T) { - //RLockFunc before Lock + // RLockFunc before Lock gtest.C(t, func(t *gtest.T) { key := "testRLockFuncBeforeLock" array := garray.New(true) @@ -169,7 +169,7 @@ func Test_Locker_RLockFunc(t *testing.T) { t.Assert(array.Len(), 2) }) - //Lock before RLockFunc + // Lock before RLockFunc gtest.C(t, func(t *gtest.T) { key := "testLockBeforeRLockFunc" array := garray.New(true) @@ -191,7 +191,7 @@ func Test_Locker_RLockFunc(t *testing.T) { t.Assert(array.Len(), 2) }) - //Lock before RLockFuncs + // Lock before RLockFuncs gtest.C(t, func(t *gtest.T) { key := "testLockBeforeRLockFuncs" array := garray.New(true) @@ -223,7 +223,7 @@ func Test_Locker_RLockFunc(t *testing.T) { } func Test_Locker_TryRLockFunc(t *testing.T) { - //Lock before TryRLockFunc + // Lock before TryRLockFunc gtest.C(t, func(t *gtest.T) { key := "testLockBeforeTryRLockFunc" array := garray.New(true) @@ -245,7 +245,7 @@ func Test_Locker_TryRLockFunc(t *testing.T) { t.Assert(array.Len(), 1) }) - //Lock before TryRLockFuncs + // Lock before TryRLockFuncs gtest.C(t, func(t *gtest.T) { key := "testLockBeforeTryRLockFuncs" array := garray.New(true) diff --git a/os/gmlock/gmlock_z_bench_test.go b/os/gmlock/gmlock_z_bench_test.go index 553500f56..b057ed933 100644 --- a/os/gmlock/gmlock_z_bench_test.go +++ b/os/gmlock/gmlock_z_bench_test.go @@ -7,8 +7,9 @@ package gmlock_test import ( - "github.com/gogf/gf/v2/os/gmlock" "testing" + + "github.com/gogf/gf/v2/os/gmlock" ) var ( diff --git a/os/gmutex/gmutex.go b/os/gmutex/gmutex.go index 1e9a35556..7de6dcdc6 100644 --- a/os/gmutex/gmutex.go +++ b/os/gmutex/gmutex.go @@ -14,7 +14,7 @@ import ( "github.com/gogf/gf/v2/container/gtype" ) -// The high level Mutex, which implements more rich features for mutex. +// Mutex The high level Mutex, which implements more rich features for mutex. type Mutex struct { state *gtype.Int32 // Indicates the state of mutex. -1: writing locked; > 1 reading locked. writer *gtype.Int32 // Pending writer count. diff --git a/os/gmutex/gmutex_unit_test.go b/os/gmutex/gmutex_unit_test.go index 24f8a5235..993dd04ff 100644 --- a/os/gmutex/gmutex_unit_test.go +++ b/os/gmutex/gmutex_unit_test.go @@ -8,11 +8,11 @@ package gmutex_test import ( "context" - "github.com/gogf/gf/v2/os/glog" "testing" "time" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gmutex" "github.com/gogf/gf/v2/test/gtest" ) @@ -41,7 +41,7 @@ func Test_Mutex_RUnlock(t *testing.T) { }) - //RLock before Lock + // RLock before Lock gtest.C(t, func(t *gtest.T) { mu := gmutex.New() mu.RLock() diff --git a/os/gproc/gproc.go b/os/gproc/gproc.go index 7519a873a..328763dd6 100644 --- a/os/gproc/gproc.go +++ b/os/gproc/gproc.go @@ -9,14 +9,14 @@ package gproc import ( "bytes" - "github.com/gogf/gf/v2/os/genv" - "github.com/gogf/gf/v2/text/gstr" "io" "os" "runtime" "time" + "github.com/gogf/gf/v2/os/genv" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/os/gproc/gproc_comm.go b/os/gproc/gproc_comm.go index 666fda1ac..a1ed5db1c 100644 --- a/os/gproc/gproc_comm.go +++ b/os/gproc/gproc_comm.go @@ -9,6 +9,7 @@ package gproc import ( "context" "fmt" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" diff --git a/os/gproc/gproc_comm_receive.go b/os/gproc/gproc_comm_receive.go index b4f991f84..c23d0dd30 100644 --- a/os/gproc/gproc_comm_receive.go +++ b/os/gproc/gproc_comm_receive.go @@ -9,11 +9,11 @@ package gproc import ( "context" "fmt" - "github.com/gogf/gf/v2/internal/json" "net" "github.com/gogf/gf/v2/container/gqueue" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/net/gtcp" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/glog" @@ -94,7 +94,7 @@ func receiveTcpHandler(conn *gtcp.Conn) { // Package decoding. msg := new(MsgRequest) if err := json.UnmarshalUseNumber(buffer, msg); err != nil { - //glog.Error(err) + // glog.Error(err) continue } if msg.RecvPid != Pid() { diff --git a/os/gproc/gproc_comm_send.go b/os/gproc/gproc_comm_send.go index a19b6377d..fee372d38 100644 --- a/os/gproc/gproc_comm_send.go +++ b/os/gproc/gproc_comm_send.go @@ -7,10 +7,11 @@ package gproc import ( + "io" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/net/gtcp" - "io" ) // Send sends data to specified process of given pid. diff --git a/os/gproc/gproc_process.go b/os/gproc/gproc_process.go index 355bf7f36..d420cece7 100644 --- a/os/gproc/gproc_process.go +++ b/os/gproc/gproc_process.go @@ -9,13 +9,14 @@ package gproc import ( "context" "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" "os" "os/exec" "runtime" "strings" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" ) // Process is the struct for a single process. @@ -123,7 +124,7 @@ func (p *Process) Kill() error { } _, err = p.Process.Wait() intlog.Error(context.TODO(), err) - //return err + // return err return nil } else { return err diff --git a/os/gproc/gproc_signal.go b/os/gproc/gproc_signal.go index a84805952..4454d8745 100644 --- a/os/gproc/gproc_signal.go +++ b/os/gproc/gproc_signal.go @@ -8,11 +8,12 @@ package gproc import ( "context" - "github.com/gogf/gf/v2/internal/intlog" "os" "os/signal" "sync" "syscall" + + "github.com/gogf/gf/v2/internal/intlog" ) // SigHandler defines a function type for signal handling. diff --git a/os/gres/gres_file.go b/os/gres/gres_file.go index ca46f0c19..c138d6455 100644 --- a/os/gres/gres_file.go +++ b/os/gres/gres_file.go @@ -9,9 +9,10 @@ package gres import ( "archive/zip" "bytes" - "github.com/gogf/gf/v2/internal/json" "io" "os" + + "github.com/gogf/gf/v2/internal/json" ) type File struct { diff --git a/os/gres/gres_func.go b/os/gres/gres_func.go index 56e75b74d..36a6b8455 100644 --- a/os/gres/gres_func.go +++ b/os/gres/gres_func.go @@ -11,6 +11,7 @@ import ( "bytes" "encoding/hex" "fmt" + "github.com/gogf/gf/v2/encoding/gbase64" "github.com/gogf/gf/v2/encoding/gcompress" "github.com/gogf/gf/v2/os/gfile" diff --git a/os/gres/gres_func_zip.go b/os/gres/gres_func_zip.go index a8011fb2a..18e8cf7ac 100644 --- a/os/gres/gres_func_zip.go +++ b/os/gres/gres_func_zip.go @@ -9,14 +9,15 @@ package gres import ( "archive/zip" "context" - "github.com/gogf/gf/v2/internal/fileinfo" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/text/gregex" "io" "os" "strings" "time" + + "github.com/gogf/gf/v2/internal/fileinfo" + "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/text/gregex" ) // ZipPathWriter compresses `paths` to `writer` using zip compressing algorithm. diff --git a/os/gres/gres_http_file.go b/os/gres/gres_http_file.go index 62c5f56db..9a06c1cbd 100644 --- a/os/gres/gres_http_file.go +++ b/os/gres/gres_http_file.go @@ -11,7 +11,7 @@ import ( "os" ) -// Close implements Close interface of http.File. +// Close implements interface of http.File. func (f *File) Close() error { return nil } diff --git a/os/gres/gres_instance.go b/os/gres/gres_instance.go index 8becdaae3..f9e3fff3f 100644 --- a/os/gres/gres_instance.go +++ b/os/gres/gres_instance.go @@ -9,7 +9,7 @@ package gres import "github.com/gogf/gf/v2/container/gmap" const ( - // Default group name for instance usage. + // DefaultName Default group name for instance usage. DefaultName = "default" ) diff --git a/os/gres/gres_resource.go b/os/gres/gres_resource.go index 7a6c35908..9c8547264 100644 --- a/os/gres/gres_resource.go +++ b/os/gres/gres_resource.go @@ -9,15 +9,14 @@ package gres import ( "context" "fmt" - "github.com/gogf/gf/v2/internal/intlog" "os" "path/filepath" "strings" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/container/gtree" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" ) type Resource struct { diff --git a/os/gres/gres_z_unit_1_test.go b/os/gres/gres_z_unit_1_test.go index abd994a86..a0cdaeca4 100644 --- a/os/gres/gres_z_unit_1_test.go +++ b/os/gres/gres_z_unit_1_test.go @@ -7,14 +7,13 @@ package gres_test import ( - "github.com/gogf/gf/v2/os/gtime" "strings" "testing" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gres" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gres/gres_z_unit_2_test.go b/os/gres/gres_z_unit_2_test.go index dd13a2120..c95fe7f9c 100644 --- a/os/gres/gres_z_unit_2_test.go +++ b/os/gres/gres_z_unit_2_test.go @@ -7,14 +7,12 @@ package gres_test import ( - _ "github.com/gogf/gf/v2/os/gres/testdata/data" - "testing" "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/test/gtest" - "github.com/gogf/gf/v2/os/gres" + _ "github.com/gogf/gf/v2/os/gres/testdata/data" + "github.com/gogf/gf/v2/test/gtest" ) func Test_Basic(t *testing.T) { diff --git a/os/grpool/grpool.go b/os/grpool/grpool.go index d463dd0ec..6aa97af04 100644 --- a/os/grpool/grpool.go +++ b/os/grpool/grpool.go @@ -9,11 +9,11 @@ package grpool import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" ) // Func is the pool function which contains context parameter. diff --git a/os/gsession/gsession_manager.go b/os/gsession/gsession_manager.go index 31116d785..192cb09a7 100644 --- a/os/gsession/gsession_manager.go +++ b/os/gsession/gsession_manager.go @@ -8,10 +8,10 @@ package gsession import ( "context" - "github.com/gogf/gf/v2/container/gmap" - "github.com/gogf/gf/v2/internal/intlog" "time" + "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gcache" ) diff --git a/os/gsession/gsession_session.go b/os/gsession/gsession_session.go index be9ee9436..5db11ac7b 100644 --- a/os/gsession/gsession_session.go +++ b/os/gsession/gsession_session.go @@ -8,13 +8,13 @@ package gsession import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" "time" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" ) // Session struct for storing single session data, which is bound to a single request. diff --git a/os/gsession/gsession_storage.go b/os/gsession/gsession_storage.go index 9e787c345..47459da35 100644 --- a/os/gsession/gsession_storage.go +++ b/os/gsession/gsession_storage.go @@ -8,8 +8,9 @@ package gsession import ( "context" - "github.com/gogf/gf/v2/container/gmap" "time" + + "github.com/gogf/gf/v2/container/gmap" ) // Storage is the interface definition for session storage. diff --git a/os/gsession/gsession_storage_file.go b/os/gsession/gsession_storage_file.go index 419af6724..c8a4d2877 100644 --- a/os/gsession/gsession_storage_file.go +++ b/os/gsession/gsession_storage_file.go @@ -8,24 +8,20 @@ package gsession import ( "context" + "os" + "time" + "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/container/gset" + "github.com/gogf/gf/v2/crypto/gaes" + "github.com/gogf/gf/v2/encoding/gbinary" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/internal/json" - "os" - "time" - - "github.com/gogf/gf/v2/crypto/gaes" - - "github.com/gogf/gf/v2/os/gtimer" - - "github.com/gogf/gf/v2/container/gset" - "github.com/gogf/gf/v2/encoding/gbinary" - - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/os/gtimer" ) // StorageFile implements the Session Storage interface with file system. diff --git a/os/gsession/gsession_storage_memory.go b/os/gsession/gsession_storage_memory.go index b6db3f387..f34a50476 100644 --- a/os/gsession/gsession_storage_memory.go +++ b/os/gsession/gsession_storage_memory.go @@ -8,8 +8,9 @@ package gsession import ( "context" - "github.com/gogf/gf/v2/container/gmap" "time" + + "github.com/gogf/gf/v2/container/gmap" ) // StorageMemory implements the Session Storage interface with memory. diff --git a/os/gsession/gsession_storage_redis.go b/os/gsession/gsession_storage_redis.go index c7c64bd02..642b0d525 100644 --- a/os/gsession/gsession_storage_redis.go +++ b/os/gsession/gsession_storage_redis.go @@ -8,12 +8,12 @@ package gsession import ( "context" + "time" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/database/gredis" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/internal/json" - "time" - "github.com/gogf/gf/v2/os/gtimer" ) diff --git a/os/gsession/gsession_unit_storage_file_test.go b/os/gsession/gsession_unit_storage_file_test.go index 5b2385215..3f2b75db0 100644 --- a/os/gsession/gsession_unit_storage_file_test.go +++ b/os/gsession/gsession_unit_storage_file_test.go @@ -8,11 +8,11 @@ package gsession_test import ( "context" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gsession" "testing" "time" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gsession" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gsession/gsession_unit_storage_memory_test.go b/os/gsession/gsession_unit_storage_memory_test.go index 237981486..02d55830e 100644 --- a/os/gsession/gsession_unit_storage_memory_test.go +++ b/os/gsession/gsession_unit_storage_memory_test.go @@ -8,11 +8,11 @@ package gsession_test import ( "context" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gsession" "testing" "time" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gsession" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gsession/gsession_unit_storage_redis_hashtable_test.go b/os/gsession/gsession_unit_storage_redis_hashtable_test.go index 7c243e779..22b5bdc44 100644 --- a/os/gsession/gsession_unit_storage_redis_hashtable_test.go +++ b/os/gsession/gsession_unit_storage_redis_hashtable_test.go @@ -8,12 +8,12 @@ package gsession_test import ( "context" - "github.com/gogf/gf/v2/database/gredis" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gsession" "testing" "time" + "github.com/gogf/gf/v2/database/gredis" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gsession" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gsession/gsession_unit_storage_redis_test.go b/os/gsession/gsession_unit_storage_redis_test.go index b6e3bb631..13461c55f 100644 --- a/os/gsession/gsession_unit_storage_redis_test.go +++ b/os/gsession/gsession_unit_storage_redis_test.go @@ -8,12 +8,12 @@ package gsession_test import ( "context" - "github.com/gogf/gf/v2/database/gredis" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gsession" "testing" "time" + "github.com/gogf/gf/v2/database/gredis" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gsession" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/os/gspath/gspath.go b/os/gspath/gspath.go index b062ead2f..e0a986cfc 100644 --- a/os/gspath/gspath.go +++ b/os/gspath/gspath.go @@ -13,15 +13,15 @@ package gspath import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/intlog" "os" "sort" "strings" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gstr" ) @@ -53,7 +53,7 @@ func New(path string, cache bool) *SPath { } if len(path) > 0 { if _, err := sp.Add(path); err != nil { - //intlog.Print(err) + // intlog.Print(err) } } return sp @@ -143,7 +143,7 @@ func (sp *SPath) Add(path string) (realPath string, err error) { } // The added path must be a directory. if gfile.IsDir(realPath) { - //fmt.Println("gspath:", realPath, sp.paths.Search(realPath)) + // fmt.Println("gspath:", realPath, sp.paths.Search(realPath)) // It will not add twice for the same directory. if sp.paths.Search(realPath) < 0 { realPath = strings.TrimRight(realPath, gfile.Separator) diff --git a/os/gtime/gtime.go b/os/gtime/gtime.go index 92240fbbc..d4d5a9877 100644 --- a/os/gtime/gtime.go +++ b/os/gtime/gtime.go @@ -11,15 +11,15 @@ package gtime import ( "fmt" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/utils" "os" "regexp" "strconv" "strings" "time" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/text/gregex" ) @@ -231,19 +231,19 @@ func StrToTime(str string, format ...string) (*Time, error) { local = time.Local ) if match = timeRegex1.FindStringSubmatch(str); len(match) > 0 && match[1] != "" { - //for k, v := range match { + // for k, v := range match { // match[k] = strings.TrimSpace(v) - //} + // } year, month, day = parseDateStr(match[1]) } else if match = timeRegex2.FindStringSubmatch(str); len(match) > 0 && match[1] != "" { - //for k, v := range match { + // for k, v := range match { // match[k] = strings.TrimSpace(v) - //} + // } year, month, day = parseDateStr(match[1]) } else if match = timeRegex3.FindStringSubmatch(str); len(match) > 0 && match[1] != "" { - //for k, v := range match { + // for k, v := range match { // match[k] = strings.TrimSpace(v) - //} + // } s := strings.Replace(match[2], ":", "", -1) if len(s) < 6 { s += strings.Repeat("0", 6-len(s)) diff --git a/os/gtime/gtime_time.go b/os/gtime/gtime_time.go index 4c92dad3e..7e28fe324 100644 --- a/os/gtime/gtime_time.go +++ b/os/gtime/gtime_time.go @@ -8,10 +8,11 @@ package gtime import ( "bytes" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "strconv" "time" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" ) // Time is a wrapper for time.Time for additional features. diff --git a/os/gtime/gtime_z_example_basic_test.go b/os/gtime/gtime_z_example_basic_test.go index a86563633..3d3ba6c92 100644 --- a/os/gtime/gtime_z_example_basic_test.go +++ b/os/gtime/gtime_z_example_basic_test.go @@ -8,6 +8,7 @@ package gtime_test import ( "fmt" + "github.com/gogf/gf/v2/os/gtime" ) diff --git a/os/gtime/gtime_z_example_time_test.go b/os/gtime/gtime_z_example_time_test.go index e88f7157c..0ac899256 100644 --- a/os/gtime/gtime_z_example_time_test.go +++ b/os/gtime/gtime_z_example_time_test.go @@ -8,9 +8,10 @@ package gtime_test import ( "fmt" - "github.com/gogf/gf/v2/os/gtime" "reflect" "time" + + "github.com/gogf/gf/v2/os/gtime" ) // New creates and returns a Time object with given parameter. diff --git a/os/gtime/gtime_z_unit_basic_test.go b/os/gtime/gtime_z_unit_basic_test.go index f3ca948d6..a65635507 100644 --- a/os/gtime/gtime_z_unit_basic_test.go +++ b/os/gtime/gtime_z_unit_basic_test.go @@ -7,10 +7,10 @@ package gtime_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" "time" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" ) @@ -18,7 +18,7 @@ import ( func Test_SetTimeZone(t *testing.T) { gtest.C(t, func(t *gtest.T) { t.Assert(gtime.SetTimeZone("Asia/Shanghai"), nil) - //t.Assert(time.Local.String(), "Asia/Shanghai") + // t.Assert(time.Local.String(), "Asia/Shanghai") }) } @@ -174,7 +174,7 @@ func Test_StrToTime(t *testing.T) { } } - //test err + // test err _, err := gtime.StrToTime("2006-01-02 15:04:05", "aabbccdd") if err == nil { t.Error("test fail") @@ -184,44 +184,44 @@ func Test_StrToTime(t *testing.T) { func Test_ConvertZone(t *testing.T) { gtest.C(t, func(t *gtest.T) { - //现行时间 + // 现行时间 nowUTC := time.Now().UTC() testZone := "America/Los_Angeles" - //转换为洛杉矶时间 + // 转换为洛杉矶时间 t1, err := gtime.ConvertZone(nowUTC.Format("2006-01-02 15:04:05"), testZone, "") if err != nil { t.Error("test fail") } - //使用洛杉矶时区解析上面转换后的时间 + // 使用洛杉矶时区解析上面转换后的时间 laStr := t1.Time.Format("2006-01-02 15:04:05") loc, err := time.LoadLocation(testZone) t2, err := time.ParseInLocation("2006-01-02 15:04:05", laStr, loc) - //判断是否与现行时间匹配 + // 判断是否与现行时间匹配 t.Assert(t2.UTC().Unix(), nowUTC.Unix()) }) - //test err + // test err gtest.C(t, func(t *gtest.T) { - //现行时间 + // 现行时间 nowUTC := time.Now().UTC() - //t.Log(nowUTC.Unix()) + // t.Log(nowUTC.Unix()) testZone := "errZone" - //错误时间输入 + // 错误时间输入 _, err := gtime.ConvertZone(nowUTC.Format("06..02 15:04:05"), testZone, "") if err == nil { t.Error("test fail") } - //错误时区输入 + // 错误时区输入 _, err = gtime.ConvertZone(nowUTC.Format("2006-01-02 15:04:05"), testZone, "") if err == nil { t.Error("test fail") } - //错误时区输入 + // 错误时区输入 _, err = gtime.ConvertZone(nowUTC.Format("2006-01-02 15:04:05"), testZone, testZone) if err == nil { t.Error("test fail") @@ -269,7 +269,7 @@ func Test_ParseTimeFromContent(t *testing.T) { timeTemp2 := gtime.ParseTimeFromContent("我是中文02.jan.2006 15:04:05我也是中文") t.Assert(timeTemp2.Time.Format("2006-01-02 15:04:05"), "2006-01-02 15:04:05") - //test err + // test err timeTempErr := gtime.ParseTimeFromContent("我是中文", "Y-m-d H:i:s") if timeTempErr != nil { t.Error("test fail") diff --git a/os/gtime/gtime_z_unit_json_test.go b/os/gtime/gtime_z_unit_json_test.go index 490a4e54e..1704ff926 100644 --- a/os/gtime/gtime_z_unit_json_test.go +++ b/os/gtime/gtime_z_unit_json_test.go @@ -7,10 +7,11 @@ package gtime_test import ( + "testing" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func Test_Json_Pointer(t *testing.T) { diff --git a/os/gtime/gtime_z_unit_sql_test.go b/os/gtime/gtime_z_unit_sql_test.go index 332dd1fdc..b4133daad 100644 --- a/os/gtime/gtime_z_unit_sql_test.go +++ b/os/gtime/gtime_z_unit_sql_test.go @@ -1,23 +1,24 @@ package gtime_test import ( + "testing" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func TestTime_Scan(t1 *testing.T) { gtest.C(t1, func(t *gtest.T) { tt := gtime.Time{} - //test string + // test string s := gtime.Now().String() t.Assert(tt.Scan(s), nil) t.Assert(tt.String(), s) - //test nano + // test nano n := gtime.TimestampNano() t.Assert(tt.Scan(n), nil) t.Assert(tt.TimestampNano(), n) - //test nil + // test nil none := (*gtime.Time)(nil) t.Assert(none.Scan(nil), nil) t.Assert(none, nil) @@ -31,7 +32,7 @@ func TestTime_Value(t1 *testing.T) { s, err := tt.Value() t.Assert(err, nil) t.Assert(s, tt.Time) - //test nil + // test nil none := (*gtime.Time)(nil) s, err = none.Value() t.Assert(err, nil) diff --git a/os/gtimer/gtimer.go b/os/gtimer/gtimer.go index 6d543c90a..f2af5133a 100644 --- a/os/gtimer/gtimer.go +++ b/os/gtimer/gtimer.go @@ -20,10 +20,10 @@ package gtimer import ( "context" - "github.com/gogf/gf/v2/container/gtype" "sync" "time" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/os/gcmd" ) diff --git a/os/gtimer/gtimer_entry.go b/os/gtimer/gtimer_entry.go index 9f645a4d9..98f85f6d0 100644 --- a/os/gtimer/gtimer_entry.go +++ b/os/gtimer/gtimer_entry.go @@ -8,6 +8,7 @@ package gtimer import ( "context" + "github.com/gogf/gf/v2/container/gtype" ) diff --git a/os/gtimer/gtimer_queue.go b/os/gtimer/gtimer_queue.go index 1a1577da8..08fdd46f3 100644 --- a/os/gtimer/gtimer_queue.go +++ b/os/gtimer/gtimer_queue.go @@ -8,9 +8,10 @@ package gtimer import ( "container/heap" - "github.com/gogf/gf/v2/container/gtype" "math" "sync" + + "github.com/gogf/gf/v2/container/gtype" ) // priorityQueue is an abstract data type similar to a regular queue or stack data structure in which diff --git a/os/gtimer/gtimer_timer.go b/os/gtimer/gtimer_timer.go index 385883f65..88859f935 100644 --- a/os/gtimer/gtimer_timer.go +++ b/os/gtimer/gtimer_timer.go @@ -8,8 +8,9 @@ package gtimer import ( "context" - "github.com/gogf/gf/v2/container/gtype" "time" + + "github.com/gogf/gf/v2/container/gtype" ) func New(options ...TimerOptions) *Timer { diff --git a/os/gtimer/gtimer_z_unit_timer_internal_test.go b/os/gtimer/gtimer_z_unit_timer_internal_test.go index 5748cf908..fda89b155 100644 --- a/os/gtimer/gtimer_z_unit_timer_internal_test.go +++ b/os/gtimer/gtimer_z_unit_timer_internal_test.go @@ -8,10 +8,11 @@ package gtimer import ( "context" - "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/test/gtest" "testing" "time" + + "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/test/gtest" ) func TestTimer_Proceed(t *testing.T) { diff --git a/os/gview/gview.go b/os/gview/gview.go index 3d9848d74..47a0f8a8c 100644 --- a/os/gview/gview.go +++ b/os/gview/gview.go @@ -12,11 +12,11 @@ package gview import ( "context" - "github.com/gogf/gf/v2/container/gmap" - "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gcmd" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/glog" diff --git a/os/gview/gview_buildin.go b/os/gview/gview_buildin.go index 3da297f9a..2728b76ed 100644 --- a/os/gview/gview_buildin.go +++ b/os/gview/gview_buildin.go @@ -9,17 +9,16 @@ package gview import ( "context" "fmt" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gutil" + htmltpl "html/template" "strings" "github.com/gogf/gf/v2/encoding/ghtml" "github.com/gogf/gf/v2/encoding/gurl" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" - - htmltpl "html/template" + "github.com/gogf/gf/v2/util/gutil" ) // buildInFuncDump implements build-in template function: dump diff --git a/os/gview/gview_config.go b/os/gview/gview_config.go index 25cc2aa77..d00beb5c7 100644 --- a/os/gview/gview_config.go +++ b/os/gview/gview_config.go @@ -8,6 +8,7 @@ package gview import ( "context" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/i18n/gi18n" @@ -146,7 +147,7 @@ func (view *View) SetPath(path string) error { view.paths.Clear() view.paths.Append(realPath) view.fileCacheMap.Clear() - //glog.Debug("[gview] SetPath:", realPath) + // glog.Debug("[gview] SetPath:", realPath) return nil } diff --git a/os/gview/gview_i18n.go b/os/gview/gview_i18n.go index d406ed118..7b3f93cf7 100644 --- a/os/gview/gview_i18n.go +++ b/os/gview/gview_i18n.go @@ -8,6 +8,7 @@ package gview import ( "context" + "github.com/gogf/gf/v2/i18n/gi18n" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/os/gview/gview_instance.go b/os/gview/gview_instance.go index 5f61fdc34..9670b4a56 100644 --- a/os/gview/gview_instance.go +++ b/os/gview/gview_instance.go @@ -9,7 +9,7 @@ package gview import "github.com/gogf/gf/v2/container/gmap" const ( - // Default group name for instance usage. + // DefaultName Default group name for instance usage. DefaultName = "default" ) diff --git a/os/gview/gview_parse.go b/os/gview/gview_parse.go index f060f951f..3fadb3d24 100644 --- a/os/gview/gview_parse.go +++ b/os/gview/gview_parse.go @@ -10,6 +10,11 @@ import ( "bytes" "context" "fmt" + htmltpl "html/template" + "strconv" + "strings" + texttpl "text/template" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/encoding/ghash" "github.com/gogf/gf/v2/errors/gcode" @@ -23,10 +28,6 @@ import ( "github.com/gogf/gf/v2/os/gspath" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gutil" - htmltpl "html/template" - "strconv" - "strings" - texttpl "text/template" ) const ( diff --git a/os/gview/gview_unit_basic_test.go b/os/gview/gview_unit_basic_test.go index 8f5cac4f6..6311f7ad7 100644 --- a/os/gview/gview_unit_basic_test.go +++ b/os/gview/gview_unit_basic_test.go @@ -8,21 +8,21 @@ package gview_test import ( "context" - "github.com/gogf/gf/v2/encoding/ghtml" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv" "io/ioutil" "os" "strings" "testing" "time" + "github.com/gogf/gf/v2/encoding/ghtml" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" ) func init() { @@ -45,13 +45,13 @@ func Test_Basic(t *testing.T) { t.Assert(err != nil, false) t.Assert(result, "hello gf,version:1.7.0;hello gf,version:1.7.0;that's all") - //测试api方法 + // 测试api方法 str = `hello {{.name}}` result, err = gview.ParseContent(context.TODO(), str, g.Map{"name": "gf"}) t.Assert(err != nil, false) t.Assert(result, "hello gf") - //测试instance方法 + // 测试instance方法 result, err = gview.Instance().ParseContent(context.TODO(), str, g.Map{"name": "gf"}) t.Assert(err != nil, false) t.Assert(result, "hello gf") @@ -224,7 +224,7 @@ func Test_FuncInclude(t *testing.T) { templatePath := gfile.Pwd() + gfile.Separator + "template" gfile.Mkdir(templatePath) defer gfile.Remove(templatePath) - //headerFile, _ := gfile.Create(templatePath + gfile.Separator + "header.html") + // headerFile, _ := gfile.Create(templatePath + gfile.Separator + "header.html") err := ioutil.WriteFile(templatePath+gfile.Separator+"header.html", []byte(header), 0644) if err != nil { t.Error(err) diff --git a/os/gview/gview_unit_config_test.go b/os/gview/gview_unit_config_test.go index 0da2cfa82..ea70d0a08 100644 --- a/os/gview/gview_unit_config_test.go +++ b/os/gview/gview_unit_config_test.go @@ -8,11 +8,12 @@ package gview_test import ( "context" + "testing" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func Test_Config(t *testing.T) { diff --git a/os/gview/gview_unit_encode_test.go b/os/gview/gview_unit_encode_test.go index 6e20b9af2..dc7913de5 100644 --- a/os/gview/gview_unit_encode_test.go +++ b/os/gview/gview_unit_encode_test.go @@ -8,12 +8,13 @@ package gview_test import ( "context" + "testing" + "github.com/gogf/gf/v2/debug/gdebug" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/test/gtest" - "testing" ) func Test_Encode_Parse(t *testing.T) { diff --git a/os/gview/gview_unit_i18n_test.go b/os/gview/gview_unit_i18n_test.go index 35fe0431c..58c1c27d5 100644 --- a/os/gview/gview_unit_i18n_test.go +++ b/os/gview/gview_unit_i18n_test.go @@ -11,9 +11,8 @@ import ( "testing" "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/os/gfile" - "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/protocol/goai/goai.go b/protocol/goai/goai.go index 231123b86..58158e462 100644 --- a/protocol/goai/goai.go +++ b/protocol/goai/goai.go @@ -12,12 +12,13 @@ package goai import ( "context" "fmt" + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/text/gstr" - "reflect" ) // OpenApiV3 is the structure defined from: diff --git a/protocol/goai/goai_parameter.go b/protocol/goai/goai_parameter.go index 23ca40314..234b9a00a 100644 --- a/protocol/goai/goai_parameter.go +++ b/protocol/goai/goai_parameter.go @@ -8,6 +8,7 @@ package goai import ( "fmt" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" diff --git a/protocol/goai/goai_path.go b/protocol/goai/goai_path.go index cd1346761..b9aaeedc6 100644 --- a/protocol/goai/goai_path.go +++ b/protocol/goai/goai_path.go @@ -7,13 +7,14 @@ package goai import ( + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/structs" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gmeta" - "reflect" ) type Path struct { diff --git a/protocol/goai/goai_requestbody.go b/protocol/goai/goai_requestbody.go index 86ff0504e..d159a6ed2 100644 --- a/protocol/goai/goai_requestbody.go +++ b/protocol/goai/goai_requestbody.go @@ -7,10 +7,11 @@ package goai import ( + "reflect" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/structs" "github.com/gogf/gf/v2/text/gstr" - "reflect" ) // RequestBody is specified by OpenAPI/Swagger 3.0 standard. diff --git a/protocol/goai/goai_response.go b/protocol/goai/goai_response.go index a5337bda9..5c9940158 100644 --- a/protocol/goai/goai_response.go +++ b/protocol/goai/goai_response.go @@ -7,10 +7,11 @@ package goai import ( + "reflect" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/structs" "github.com/gogf/gf/v2/text/gstr" - "reflect" ) // Response is specified by OpenAPI/Swagger 3.0 standard. diff --git a/protocol/goai/goai_shema.go b/protocol/goai/goai_shema.go index 7558762ec..1a6192750 100644 --- a/protocol/goai/goai_shema.go +++ b/protocol/goai/goai_shema.go @@ -7,13 +7,14 @@ package goai import ( + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/structs" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gmeta" - "reflect" ) type Schemas map[string]SchemaRef diff --git a/protocol/goai/goai_shemaref.go b/protocol/goai/goai_shemaref.go index fcd15df2c..9dcd97ff1 100644 --- a/protocol/goai/goai_shemaref.go +++ b/protocol/goai/goai_shemaref.go @@ -7,11 +7,12 @@ package goai import ( + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/util/gconv" - "reflect" ) type SchemaRefs []SchemaRef diff --git a/protocol/goai/goai_test.go b/protocol/goai/goai_test.go index e079884fb..9acda5b21 100644 --- a/protocol/goai/goai_test.go +++ b/protocol/goai/goai_test.go @@ -9,11 +9,12 @@ package goai_test import ( "context" "fmt" + "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/protocol/goai" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gmeta" - "testing" ) func Test_Basic(t *testing.T) { @@ -105,7 +106,7 @@ func TestOpenApiV3_Add(t *testing.T) { Object: f, }) t.AssertNil(err) - //fmt.Println(oai.String()) + // fmt.Println(oai.String()) // Schema asserts. t.Assert(len(oai.Components.Schemas), 3) t.Assert(oai.Components.Schemas[`github.com.gogf.gf.v2.protocol.goai_test.CreateResourceReq`].Value.Type, goai.TypeObject) @@ -317,7 +318,7 @@ func TestOpenApiV3_CommonRequest_WithoutDataField_Setting(t *testing.T) { }) t.AssertNil(err) // Schema asserts. - //fmt.Println(oai.String()) + // fmt.Println(oai.String()) t.Assert(len(oai.Components.Schemas), 3) t.Assert(len(oai.Paths), 1) t.Assert(len(oai.Paths["/index"].Put.RequestBody.Value.Content["application/json"].Schema.Value.Properties), 5) @@ -357,7 +358,7 @@ func TestOpenApiV3_CommonRequest_EmptyRequest(t *testing.T) { }) t.AssertNil(err) // Schema asserts. - //fmt.Println(oai.String()) + // fmt.Println(oai.String()) t.Assert(len(oai.Components.Schemas), 3) t.Assert(len(oai.Paths), 1) t.Assert(len(oai.Paths["/index"].Put.RequestBody.Value.Content["application/json"].Schema.Value.Properties), 3) @@ -412,7 +413,7 @@ func TestOpenApiV3_CommonRequest_SubDataField(t *testing.T) { }) t.AssertNil(err) // Schema asserts. - //fmt.Println(oai.String()) + // fmt.Println(oai.String()) t.Assert(len(oai.Components.Schemas), 4) t.Assert(len(oai.Paths), 1) t.Assert(len(oai.Paths["/index"].Put.RequestBody.Value.Content["application/json"].Schema.Value.Properties), 1) @@ -543,7 +544,7 @@ func TestOpenApiV3_CommonResponse_EmptyResponse(t *testing.T) { }) t.AssertNil(err) // Schema asserts. - //fmt.Println(oai.String()) + // fmt.Println(oai.String()) t.Assert(len(oai.Components.Schemas), 3) t.Assert(len(oai.Paths), 1) t.Assert(oai.Paths["/index"].Put.RequestBody.Value.Content["application/json"].Schema.Ref, `github.com.gogf.gf.v2.protocol.goai_test.Req`) @@ -599,7 +600,7 @@ func TestOpenApiV3_CommonResponse_SubDataField(t *testing.T) { }) t.AssertNil(err) // Schema asserts. - //fmt.Println(oai.String()) + // fmt.Println(oai.String()) t.Assert(len(oai.Components.Schemas), 4) t.Assert(len(oai.Paths), 1) t.Assert(len(oai.Paths["/index"].Get.Responses["200"].Value.Content["application/json"].Schema.Value.Properties), 1) @@ -654,7 +655,7 @@ func TestOpenApiV3_ShortTags(t *testing.T) { Object: f, }) t.AssertNil(err) - //fmt.Println(oai.String()) + // fmt.Println(oai.String()) // Schema asserts. t.Assert(len(oai.Components.Schemas), 3) t.Assert(oai.Paths[`/test1/{appId}`].Summary, `CreateResourceReq sum`) @@ -690,7 +691,7 @@ func TestOpenApiV3_HtmlResponse(t *testing.T) { }) t.AssertNil(err) - //fmt.Println(oai.String()) + // fmt.Println(oai.String()) t.Assert(oai.Components.Schemas[`github.com.gogf.gf.v2.protocol.goai_test.Res`].Value.Type, goai.TypeString) }) } @@ -737,7 +738,7 @@ func TestOpenApiV3_HtmlResponseWithCommonResponse(t *testing.T) { }) t.AssertNil(err) - //fmt.Println(oai.String()) + // fmt.Println(oai.String()) t.Assert(oai.Components.Schemas[`github.com.gogf.gf.v2.protocol.goai_test.Res`].Value.Type, goai.TypeString) }) } diff --git a/test/gtest/gtest_util.go b/test/gtest/gtest_util.go index 387a24c33..8f2913fe8 100644 --- a/test/gtest/gtest_util.go +++ b/test/gtest/gtest_util.go @@ -8,7 +8,6 @@ package gtest import ( "fmt" - "github.com/gogf/gf/v2/internal/empty" "io/ioutil" "os" "path/filepath" @@ -16,7 +15,7 @@ import ( "testing" "github.com/gogf/gf/v2/debug/gdebug" - + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/text/gregex/gregex_z_example_test.go b/text/gregex/gregex_z_example_test.go index ecf6128d7..789751444 100644 --- a/text/gregex/gregex_z_example_test.go +++ b/text/gregex/gregex_z_example_test.go @@ -7,9 +7,10 @@ package gregex_test import ( "bytes" + "strings" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/text/gregex" - "strings" ) func ExampleIsMatch() { diff --git a/text/gstr/gstr.go b/text/gstr/gstr.go index bc7b4d7bb..e783a9a0b 100644 --- a/text/gstr/gstr.go +++ b/text/gstr/gstr.go @@ -17,9 +17,7 @@ import ( "unicode/utf8" "github.com/gogf/gf/v2/internal/utils" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/util/grand" ) diff --git a/util/gconv/gconv.go b/util/gconv/gconv.go index a0809d13a..60c4b3252 100644 --- a/util/gconv/gconv.go +++ b/util/gconv/gconv.go @@ -11,8 +11,6 @@ package gconv import ( "fmt" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/os/gtime" "math" "reflect" "strconv" @@ -20,6 +18,8 @@ import ( "time" "github.com/gogf/gf/v2/encoding/gbinary" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/os/gtime" ) var ( diff --git a/util/gconv/gconv_map.go b/util/gconv/gconv_map.go index 811153499..13f7d5e8f 100644 --- a/util/gconv/gconv_map.go +++ b/util/gconv/gconv_map.go @@ -7,11 +7,11 @@ package gconv import ( - "github.com/gogf/gf/v2/internal/json" "reflect" "strings" "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/utils" ) diff --git a/util/gconv/gconv_maptomap.go b/util/gconv/gconv_maptomap.go index 498a22082..51eb0efda 100644 --- a/util/gconv/gconv_maptomap.go +++ b/util/gconv/gconv_maptomap.go @@ -7,10 +7,11 @@ package gconv import ( + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" - "reflect" ) // MapToMap converts any map type variable `params` to another map type variable `pointer` diff --git a/util/gconv/gconv_maptomaps.go b/util/gconv/gconv_maptomaps.go index 28289a0e2..6ab8e2199 100644 --- a/util/gconv/gconv_maptomaps.go +++ b/util/gconv/gconv_maptomaps.go @@ -7,10 +7,11 @@ package gconv import ( + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" - "reflect" ) // MapToMaps converts any slice type variable `params` to another map slice type variable `pointer`. diff --git a/util/gconv/gconv_scan.go b/util/gconv/gconv_scan.go index 5472bdd83..25555da65 100644 --- a/util/gconv/gconv_scan.go +++ b/util/gconv/gconv_scan.go @@ -8,11 +8,12 @@ package gconv import ( "database/sql" + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/structs" "github.com/gogf/gf/v2/internal/utils" - "reflect" ) // Scan automatically checks the type of `pointer` and converts `params` to `pointer`. It supports `pointer` @@ -406,7 +407,7 @@ func doScanList(structSlice interface{}, structSlicePointer interface{}, bindToA if len(relationDataMap) > 0 { relationFromAttrField = relationFromAttrValue.FieldByName(relationBindToFieldName) if relationFromAttrField.IsValid() { - //results := make(Result, 0) + // results := make(Result, 0) results := make([]interface{}, 0) for _, v := range SliceAny(relationDataMap[String(relationFromAttrField.Interface())]) { item := v diff --git a/util/gconv/gconv_struct.go b/util/gconv/gconv_struct.go index 1546efae4..ad400507a 100644 --- a/util/gconv/gconv_struct.go +++ b/util/gconv/gconv_struct.go @@ -7,14 +7,14 @@ package gconv import ( + "reflect" + "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/structs" - "reflect" - "strings" - "github.com/gogf/gf/v2/internal/utils" ) @@ -162,9 +162,9 @@ func doStruct(params interface{}, pointer interface{}, mapping map[string]string e := reflect.New(pointerElemReflectValue.Type().Elem()).Elem() pointerElemReflectValue.Set(e.Addr()) } - //if v, ok := pointerElemReflectValue.Interface().(iUnmarshalValue); ok { + // if v, ok := pointerElemReflectValue.Interface().(iUnmarshalValue); ok { // return v.UnmarshalValue(params) - //} + // } // Note that it's `pointerElemReflectValue` here not `pointerReflectValue`. if err, ok := bindVarToReflectValueWithInterfaceCheck(pointerElemReflectValue, paramsInterface); ok { return err diff --git a/util/gconv/gconv_structs.go b/util/gconv/gconv_structs.go index 83db3548b..bb73319fe 100644 --- a/util/gconv/gconv_structs.go +++ b/util/gconv/gconv_structs.go @@ -7,10 +7,11 @@ package gconv import ( + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" - "reflect" ) // Structs converts any slice to given struct slice. diff --git a/util/gmeta/gmeta_unit_test.go b/util/gmeta/gmeta_unit_test.go index db167b2b4..d65e284a7 100644 --- a/util/gmeta/gmeta_unit_test.go +++ b/util/gmeta/gmeta_unit_test.go @@ -7,12 +7,12 @@ package gmeta_test import ( - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/util/gmeta" "testing" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gmeta" ) func TestMeta_Basic(t *testing.T) { diff --git a/util/gmode/gmode_test.go b/util/gmode/gmode_test.go index 507cfaeb1..bbc019160 100644 --- a/util/gmode/gmode_test.go +++ b/util/gmode/gmode_test.go @@ -9,10 +9,10 @@ package gmode_test import ( - "github.com/gogf/gf/v2/util/gmode" "testing" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gmode" ) func Test_AutoCheckSourceCodes(t *testing.T) { diff --git a/util/gpage/gpage.go b/util/gpage/gpage.go index 118fdb9cb..af400d9b7 100644 --- a/util/gpage/gpage.go +++ b/util/gpage/gpage.go @@ -9,9 +9,10 @@ package gpage import ( "fmt" + "math" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" - "math" ) // Page is the pagination implementer. diff --git a/util/gpage/gpage_unit_test.go b/util/gpage/gpage_unit_test.go index 3b9e9832c..798813305 100644 --- a/util/gpage/gpage_unit_test.go +++ b/util/gpage/gpage_unit_test.go @@ -9,10 +9,10 @@ package gpage_test import ( - "github.com/gogf/gf/v2/util/gpage" "testing" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gpage" ) func Test_New(t *testing.T) { diff --git a/util/grand/grand_z_bench_test.go b/util/grand/grand_z_bench_test.go index 2fccac4ad..d52cdef7d 100644 --- a/util/grand/grand_z_bench_test.go +++ b/util/grand/grand_z_bench_test.go @@ -10,11 +10,11 @@ package grand_test import ( cryptoRand "crypto/rand" - mathRand "math/rand" - "encoding/binary" - "github.com/gogf/gf/v2/util/grand" + mathRand "math/rand" "testing" + + "github.com/gogf/gf/v2/util/grand" ) var ( diff --git a/util/grand/grand_z_unit_test.go b/util/grand/grand_z_unit_test.go index cea08a076..1a4a095ad 100644 --- a/util/grand/grand_z_unit_test.go +++ b/util/grand/grand_z_unit_test.go @@ -9,11 +9,11 @@ package grand_test import ( - "github.com/gogf/gf/v2/text/gstr" "testing" "time" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/grand" ) diff --git a/util/guid/guid.go b/util/guid/guid.go index 8686f31be..2259abb81 100644 --- a/util/guid/guid.go +++ b/util/guid/guid.go @@ -7,13 +7,14 @@ package guid import ( + "os" + "strconv" + "time" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/encoding/ghash" "github.com/gogf/gf/v2/net/gipv4" "github.com/gogf/gf/v2/util/grand" - "os" - "strconv" - "time" ) const ( diff --git a/util/guid/guid_z_bench_test.go b/util/guid/guid_z_bench_test.go index c5b88a650..282bc76ad 100644 --- a/util/guid/guid_z_bench_test.go +++ b/util/guid/guid_z_bench_test.go @@ -9,8 +9,9 @@ package guid_test import ( - "github.com/gogf/gf/v2/util/guid" "testing" + + "github.com/gogf/gf/v2/util/guid" ) func Benchmark_S(b *testing.B) { diff --git a/util/guid/guid_z_unit_test.go b/util/guid/guid_z_unit_test.go index cbd667f0c..52d106f64 100644 --- a/util/guid/guid_z_unit_test.go +++ b/util/guid/guid_z_unit_test.go @@ -9,11 +9,11 @@ package guid_test import ( - "github.com/gogf/gf/v2/container/gset" - "github.com/gogf/gf/v2/util/guid" "testing" + "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/guid" ) func Test_S(t *testing.T) { diff --git a/util/gutil/gutil.go b/util/gutil/gutil.go index b7a3ed32e..172798b1c 100644 --- a/util/gutil/gutil.go +++ b/util/gutil/gutil.go @@ -9,11 +9,12 @@ package gutil import ( "fmt" + "reflect" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/util/gconv" - "reflect" ) const ( diff --git a/util/gutil/gutil_dump.go b/util/gutil/gutil_dump.go index fb41864ae..fe97476b4 100644 --- a/util/gutil/gutil_dump.go +++ b/util/gutil/gutil_dump.go @@ -9,10 +9,11 @@ package gutil import ( "bytes" "fmt" - "github.com/gogf/gf/v2/internal/structs" - "github.com/gogf/gf/v2/text/gstr" "reflect" "strings" + + "github.com/gogf/gf/v2/internal/structs" + "github.com/gogf/gf/v2/text/gstr" ) // iString is used for type assert api for String(). diff --git a/util/gutil/gutil_list.go b/util/gutil/gutil_list.go index 12a8735e3..9a60a3182 100644 --- a/util/gutil/gutil_list.go +++ b/util/gutil/gutil_list.go @@ -7,8 +7,9 @@ package gutil import ( - "github.com/gogf/gf/v2/internal/utils" "reflect" + + "github.com/gogf/gf/v2/internal/utils" ) // ListItemValues retrieves and returns the elements of all item struct/map with key `key`. diff --git a/util/gutil/gutil_map.go b/util/gutil/gutil_map.go index 2b5246e91..8be8af5a6 100644 --- a/util/gutil/gutil_map.go +++ b/util/gutil/gutil_map.go @@ -7,8 +7,9 @@ package gutil import ( - "github.com/gogf/gf/v2/internal/utils" "reflect" + + "github.com/gogf/gf/v2/internal/utils" ) // MapCopy does a shallow copy from map `data` to `copy` for most commonly used map type diff --git a/util/gutil/gutil_slice.go b/util/gutil/gutil_slice.go index 67b61ddab..a9af34220 100644 --- a/util/gutil/gutil_slice.go +++ b/util/gutil/gutil_slice.go @@ -7,8 +7,9 @@ package gutil import ( - "github.com/gogf/gf/v2/util/gconv" "reflect" + + "github.com/gogf/gf/v2/util/gconv" ) // SliceCopy does a shallow copy of slice `data` for most commonly used slice type diff --git a/util/gutil/gutil_struct.go b/util/gutil/gutil_struct.go index e02c3e471..bd856fc4b 100644 --- a/util/gutil/gutil_struct.go +++ b/util/gutil/gutil_struct.go @@ -7,8 +7,9 @@ package gutil import ( - "github.com/gogf/gf/v2/util/gconv" "reflect" + + "github.com/gogf/gf/v2/util/gconv" ) // StructToSlice converts struct to slice of which all keys and values are its items. diff --git a/util/gutil/gutil_z_unit_dump_test.go b/util/gutil/gutil_z_unit_dump_test.go index 236d07add..2e0d9a2d1 100755 --- a/util/gutil/gutil_z_unit_dump_test.go +++ b/util/gutil/gutil_z_unit_dump_test.go @@ -7,12 +7,12 @@ package gutil_test import ( - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gmeta" "testing" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gmeta" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/util/gutil/gutil_z_unit_list_test.go b/util/gutil/gutil_z_unit_list_test.go index a324a4a58..7b731cd14 100755 --- a/util/gutil/gutil_z_unit_list_test.go +++ b/util/gutil/gutil_z_unit_list_test.go @@ -7,9 +7,9 @@ package gutil_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/util/gutil/gutil_z_unit_map_test.go b/util/gutil/gutil_z_unit_map_test.go index c7caa5ecb..b51939e43 100755 --- a/util/gutil/gutil_z_unit_map_test.go +++ b/util/gutil/gutil_z_unit_map_test.go @@ -7,9 +7,9 @@ package gutil_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/util/gutil/gutil_z_unit_slice_test.go b/util/gutil/gutil_z_unit_slice_test.go index 5e9bb5155..08c37d480 100755 --- a/util/gutil/gutil_z_unit_slice_test.go +++ b/util/gutil/gutil_z_unit_slice_test.go @@ -7,9 +7,9 @@ package gutil_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/util/gutil/gutil_z_unit_struct_test.go b/util/gutil/gutil_z_unit_struct_test.go index cf4a1685d..20ea6dcae 100755 --- a/util/gutil/gutil_z_unit_struct_test.go +++ b/util/gutil/gutil_z_unit_struct_test.go @@ -7,9 +7,9 @@ package gutil_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/util/gutil/gutil_z_unit_test.go b/util/gutil/gutil_z_unit_test.go index 0459ad4f7..fe69defc1 100755 --- a/util/gutil/gutil_z_unit_test.go +++ b/util/gutil/gutil_z_unit_test.go @@ -7,9 +7,9 @@ package gutil_test import ( - "github.com/gogf/gf/v2/frame/g" "testing" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/util/gvalid/gvalid_custom_rule.go b/util/gvalid/gvalid_custom_rule.go index 11fe6da87..73dc0e648 100644 --- a/util/gvalid/gvalid_custom_rule.go +++ b/util/gvalid/gvalid_custom_rule.go @@ -8,6 +8,7 @@ package gvalid import ( "context" + "github.com/gogf/gf/v2/container/gvar" ) diff --git a/util/gvalid/gvalid_error.go b/util/gvalid/gvalid_error.go index 21e0a0aeb..ba252d8c6 100644 --- a/util/gvalid/gvalid_error.go +++ b/util/gvalid/gvalid_error.go @@ -7,10 +7,11 @@ package gvalid import ( + "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/text/gstr" - "strings" ) // Error is the validation error for validation result. diff --git a/util/gvalid/gvalid_validator_check_map.go b/util/gvalid/gvalid_validator_check_map.go index ff756ead1..9bbf3d62a 100644 --- a/util/gvalid/gvalid_validator_check_map.go +++ b/util/gvalid/gvalid_validator_check_map.go @@ -9,9 +9,10 @@ package gvalid import ( "context" "errors" + "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/util/gconv" - "strings" ) // CheckMap validates map and returns the error result. It returns nil if with successful validation. diff --git a/util/gvalid/gvalid_validator_check_struct.go b/util/gvalid/gvalid_validator_check_struct.go index 69db1341b..7b6c1d5bc 100644 --- a/util/gvalid/gvalid_validator_check_struct.go +++ b/util/gvalid/gvalid_validator_check_struct.go @@ -8,11 +8,12 @@ package gvalid import ( "context" + "strings" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/internal/structs" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gutil" - "strings" ) // CheckStruct validates struct and returns the error result. diff --git a/util/gvalid/gvalid_validator_check_value.go b/util/gvalid/gvalid_validator_check_value.go index bb6cd4dc2..0cfa78fcc 100644 --- a/util/gvalid/gvalid_validator_check_value.go +++ b/util/gvalid/gvalid_validator_check_value.go @@ -9,19 +9,19 @@ package gvalid import ( "context" "errors" - "github.com/gogf/gf/v2/container/gvar" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/text/gstr" "strconv" "strings" "time" + "github.com/gogf/gf/v2/container/gvar" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/net/gipv4" "github.com/gogf/gf/v2/net/gipv6" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/util/gvalid/gvalid_validator_rule_length.go b/util/gvalid/gvalid_validator_rule_length.go index 7b5b13c21..7955e5ac2 100644 --- a/util/gvalid/gvalid_validator_rule_length.go +++ b/util/gvalid/gvalid_validator_rule_length.go @@ -8,9 +8,10 @@ package gvalid import ( "context" - "github.com/gogf/gf/v2/util/gconv" "strconv" "strings" + + "github.com/gogf/gf/v2/util/gconv" ) // checkLength checks `value` using length rules. diff --git a/util/gvalid/gvalid_validator_rule_required.go b/util/gvalid/gvalid_validator_rule_required.go index 14470f96d..06de0c50d 100644 --- a/util/gvalid/gvalid_validator_rule_required.go +++ b/util/gvalid/gvalid_validator_rule_required.go @@ -7,11 +7,12 @@ package gvalid import ( + "reflect" + "strings" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gutil" - "reflect" - "strings" ) // checkRequired checks `value` using required rules. diff --git a/util/gvalid/gvalid_validator_rule_resident_id.go b/util/gvalid/gvalid_validator_rule_resident_id.go index a991de473..df4555924 100644 --- a/util/gvalid/gvalid_validator_rule_resident_id.go +++ b/util/gvalid/gvalid_validator_rule_resident_id.go @@ -7,9 +7,10 @@ package gvalid import ( - "github.com/gogf/gf/v2/text/gregex" "strconv" "strings" + + "github.com/gogf/gf/v2/text/gregex" ) // checkResidentId checks whether given id a china resident id number. diff --git a/util/gvalid/gvalid_z_example_test.go b/util/gvalid/gvalid_z_example_test.go index 5f91c79a6..3f04cab1b 100644 --- a/util/gvalid/gvalid_z_example_test.go +++ b/util/gvalid/gvalid_z_example_test.go @@ -10,14 +10,15 @@ import ( "context" "errors" "fmt" + "math" + "reflect" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gvalid" - "math" - "reflect" ) func ExampleCheckMap() { @@ -245,15 +246,15 @@ func ExampleValidator_CheckMap() { } // May Output: - //{ + // { // "passport": { // "length": "账号长度应当在6到16之间", // "required": "账号不能为空" - //}, + // }, // "password": { // "same": "两次密码输入不相等" - //} - //} + // } + // } } func ExampleValidator_CheckStruct() { diff --git a/util/gvalid/gvalid_z_unit_basic_all_test.go b/util/gvalid/gvalid_z_unit_basic_all_test.go index c1b0fb118..d1077000d 100755 --- a/util/gvalid/gvalid_z_unit_basic_all_test.go +++ b/util/gvalid/gvalid_z_unit_basic_all_test.go @@ -8,14 +8,14 @@ package gvalid_test import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gtime" "testing" "time" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gvalid" ) @@ -670,10 +670,10 @@ func Test_Domain(t *testing.T) { for k, v := range m { err = gvalid.CheckValue(context.TODO(), k, "domain", nil) if v { - //fmt.Println(k) + // fmt.Println(k) t.Assert(err, nil) } else { - //fmt.Println(k) + // fmt.Println(k) t.AssertNE(err, nil) } } diff --git a/util/gvalid/gvalid_z_unit_checkmap_test.go b/util/gvalid/gvalid_z_unit_checkmap_test.go index 06accec61..27a618a47 100755 --- a/util/gvalid/gvalid_z_unit_checkmap_test.go +++ b/util/gvalid/gvalid_z_unit_checkmap_test.go @@ -8,10 +8,10 @@ package gvalid_test import ( "context" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" "testing" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gvalid" ) diff --git a/util/gvalid/gvalid_z_unit_checkstruct_test.go b/util/gvalid/gvalid_z_unit_checkstruct_test.go index 809990e2e..9b16d391f 100755 --- a/util/gvalid/gvalid_z_unit_checkstruct_test.go +++ b/util/gvalid/gvalid_z_unit_checkstruct_test.go @@ -8,12 +8,11 @@ package gvalid_test import ( "context" - "github.com/gogf/gf/v2/container/gvar" - "github.com/gogf/gf/v2/os/gtime" "testing" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/frame/g" - + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gvalid" ) diff --git a/util/gvalid/gvalid_z_unit_i18n_test.go b/util/gvalid/gvalid_z_unit_i18n_test.go index 4a8b5551a..6e61ff636 100644 --- a/util/gvalid/gvalid_z_unit_i18n_test.go +++ b/util/gvalid/gvalid_z_unit_i18n_test.go @@ -8,12 +8,12 @@ package gvalid_test import ( "context" - "github.com/gogf/gf/v2/debug/gdebug" - "github.com/gogf/gf/v2/i18n/gi18n" - "github.com/gogf/gf/v2/util/gvalid" "testing" + "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/i18n/gi18n" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gvalid" ) func TestValidator_I18n(t *testing.T) {