From 4fa2a879d786becfa49baca0bebb9a7571acd13b Mon Sep 17 00:00:00 2001 From: houseme Date: Mon, 15 Nov 2021 20:49:02 +0800 Subject: [PATCH] [feature] improve code gview --- os/gmlock/gmlock_unit_rlock_test.go | 20 ++++++------- os/gmlock/gmlock_z_bench_test.go | 3 +- os/gmutex/gmutex.go | 2 +- os/gmutex/gmutex_unit_test.go | 4 +-- os/gproc/gproc.go | 4 +-- os/gproc/gproc_comm.go | 1 + os/gproc/gproc_comm_receive.go | 4 +-- os/gproc/gproc_comm_send.go | 3 +- os/gproc/gproc_process.go | 9 +++--- os/gproc/gproc_signal.go | 3 +- os/gres/gres_file.go | 3 +- os/gres/gres_func.go | 1 + os/gres/gres_func_zip.go | 9 +++--- os/gres/gres_http_file.go | 2 +- os/gres/gres_instance.go | 2 +- os/gres/gres_resource.go | 5 ++-- os/gres/gres_z_unit_1_test.go | 5 ++-- os/gres/gres_z_unit_2_test.go | 6 ++-- os/grpool/grpool.go | 4 +-- os/gsession/gsession_manager.go | 4 +-- os/gsession/gsession_session.go | 6 ++-- os/gsession/gsession_storage.go | 3 +- os/gsession/gsession_storage_file.go | 20 ++++++------- os/gsession/gsession_storage_memory.go | 3 +- os/gsession/gsession_storage_redis.go | 4 +-- .../gsession_unit_storage_file_test.go | 4 +-- .../gsession_unit_storage_memory_test.go | 4 +-- ...ssion_unit_storage_redis_hashtable_test.go | 6 ++-- .../gsession_unit_storage_redis_test.go | 6 ++-- os/gspath/gspath.go | 10 +++---- os/gtime/gtime.go | 18 ++++++------ os/gtime/gtime_time.go | 5 ++-- os/gtime/gtime_z_unit_basic_test.go | 28 +++++++++---------- os/gtime/gtime_z_unit_json_test.go | 3 +- os/gtime/gtime_z_unit_sql_test.go | 11 ++++---- os/gtimer/gtimer.go | 2 +- os/gtimer/gtimer_entry.go | 1 + os/gtimer/gtimer_queue.go | 3 +- os/gtimer/gtimer_timer.go | 3 +- .../gtimer_z_unit_timer_internal_test.go | 5 ++-- os/gview/gview.go | 4 +-- os/gview/gview_buildin.go | 7 ++--- os/gview/gview_config.go | 3 +- os/gview/gview_i18n.go | 1 + os/gview/gview_instance.go | 2 +- os/gview/gview_parse.go | 9 +++--- os/gview/gview_unit_basic_test.go | 14 +++++----- os/gview/gview_unit_config_test.go | 3 +- os/gview/gview_unit_encode_test.go | 3 +- os/gview/gview_unit_i18n_test.go | 3 +- 50 files changed, 150 insertions(+), 138 deletions(-) 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_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" )