This commit is contained in:
John Guo 2021-11-16 00:42:44 +08:00
commit e92aaa0891
113 changed files with 295 additions and 259 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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"
)

View File

@ -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 {

View File

@ -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 {

View File

@ -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()
}

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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() {

View File

@ -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")
}
})
}

View File

@ -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"

View File

@ -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"

View File

@ -8,6 +8,7 @@ package gcfg
import (
"context"
"github.com/gogf/gf/v2/internal/intlog"
)

View File

@ -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"

View File

@ -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) {

View File

@ -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"
)

View File

@ -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 (

View File

@ -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 (

View File

@ -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.

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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)

View File

@ -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"
)

View File

@ -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,

View File

@ -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"

View File

@ -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"
)

View File

@ -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 (

View File

@ -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`.

View File

@ -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.

View File

@ -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 (

View File

@ -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:

View File

@ -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 (

View File

@ -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) {

View File

@ -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 {

View File

@ -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) {

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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) {

View File

@ -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, "")

View File

@ -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.

View File

@ -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{} {

View File

@ -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)
//})
// })
}

View File

@ -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"
)

View File

@ -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.

View File

@ -8,6 +8,7 @@ package gfsnotify
import (
"context"
"github.com/gogf/gf/v2/container/glist"
"github.com/gogf/gf/v2/internal/intlog"
)

View File

@ -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)

View File

@ -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.

View File

@ -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
}

View File

@ -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,

View File

@ -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 (

View File

@ -8,6 +8,7 @@ package glog_test
import (
"context"
"github.com/gogf/gf/v2/frame/g"
)

View File

@ -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 (

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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()

View File

@ -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) {

View File

@ -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 (

View File

@ -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)

View File

@ -7,8 +7,9 @@
package gmlock_test
import (
"github.com/gogf/gf/v2/os/gmlock"
"testing"
"github.com/gogf/gf/v2/os/gmlock"
)
var (

View File

@ -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.

View File

@ -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()

View File

@ -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"
)

View File

@ -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"

View File

@ -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() {

View File

@ -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.

View File

@ -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

View File

@ -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.

View File

@ -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 {

View File

@ -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"

View File

@ -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.

View File

@ -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
}

View File

@ -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"
)

View File

@ -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 {

View File

@ -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"
)

View File

@ -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) {

View File

@ -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.

View File

@ -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"
)

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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"
)

View File

@ -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)

View File

@ -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))

View File

@ -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.

View File

@ -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")

View File

@ -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) {

View File

@ -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)

View File

@ -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"
)

View File

@ -8,6 +8,7 @@ package gtimer
import (
"context"
"github.com/gogf/gf/v2/container/gtype"
)

Some files were not shown because too many files have changed in this diff Show More