From 7df53ff55e3b682d652dce7c2b7c667512d00d06 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 20 Jan 2020 14:14:11 +0800 Subject: [PATCH] rename all timestamp function names from *Second to Timestamp* --- .example/encoding/gjson/gjson.go | 32 +++++++++---------- .example/net/ghttp/server/session/session.go | 2 +- .../monitor/gtcp_monitor_client.go | 2 +- .example/os/grpool/goroutine.go | 4 +-- .example/os/grpool/grpool.go | 4 +-- .example/os/gtime/gtime_func.go | 8 ++--- container/gpool/gpool.go | 6 ++-- database/gredis/gredis_unit_test.go | 2 +- frame/gins/gins_config_test.go | 8 ++--- frame/gins/gins_view_test.go | 2 +- i18n/gi18n/gi18n_unit_test.go | 2 +- net/ghttp/ghttp_server_admin_process.go | 6 ++-- net/ghttp/ghttp_server_cookie.go | 2 +- os/gcache/gcache_mem_cache.go | 8 ++--- os/gcache/gcache_mem_cache_item.go | 2 +- os/genv/genv_test.go | 10 +++--- os/gfile/gfile_z_test.go | 6 ++-- os/gfsnotify/gfsnotify_z_unit_test.go | 12 +++---- os/gsession/gsession.go | 2 +- os/gsession/gsession_storage_file.go | 6 ++-- os/gtime/gtime_z_bench_test.go | 8 ++--- os/gtime/gtime_z_unit_basic_test.go | 8 ++--- os/gview/gview_unit_basic_test.go | 2 +- 23 files changed, 72 insertions(+), 72 deletions(-) diff --git a/.example/encoding/gjson/gjson.go b/.example/encoding/gjson/gjson.go index bb77e3106..5b2510930 100644 --- a/.example/encoding/gjson/gjson.go +++ b/.example/encoding/gjson/gjson.go @@ -100,53 +100,53 @@ func testConvert() { func testSplitChar() { var v interface{} j := gjson.New(nil) - t1 := gtime.Nanosecond() + t1 := gtime.TimestampNano() j.Set("a.b.c.d.e.f.g.h.i.j.k", 1) - t2 := gtime.Nanosecond() + t2 := gtime.TimestampNano() fmt.Println(t2 - t1) - t5 := gtime.Nanosecond() + t5 := gtime.TimestampNano() v = j.Get("a.b.c.d.e.f.g.h.i.j.k") - t6 := gtime.Nanosecond() + t6 := gtime.TimestampNano() fmt.Println(v) fmt.Println(t6 - t5) j.SetSplitChar('#') - t7 := gtime.Nanosecond() + t7 := gtime.TimestampNano() v = j.Get("a#b#c#d#e#f#g#h#i#j#k") - t8 := gtime.Nanosecond() + t8 := gtime.TimestampNano() fmt.Println(v) fmt.Println(t8 - t7) } func testViolenceCheck() { j := gjson.New(nil) - t1 := gtime.Nanosecond() + t1 := gtime.TimestampNano() j.Set("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", 1) - t2 := gtime.Nanosecond() + t2 := gtime.TimestampNano() fmt.Println(t2 - t1) - t3 := gtime.Nanosecond() + t3 := gtime.TimestampNano() j.Set("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", 1) - t4 := gtime.Nanosecond() + t4 := gtime.TimestampNano() fmt.Println(t4 - t3) - t5 := gtime.Nanosecond() + t5 := gtime.TimestampNano() j.Get("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a") - t6 := gtime.Nanosecond() + t6 := gtime.TimestampNano() fmt.Println(t6 - t5) j.SetViolenceCheck(false) - t7 := gtime.Nanosecond() + t7 := gtime.TimestampNano() j.Set("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a", 1) - t8 := gtime.Nanosecond() + t8 := gtime.TimestampNano() fmt.Println(t8 - t7) - t9 := gtime.Nanosecond() + t9 := gtime.TimestampNano() j.Get("a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a") - t10 := gtime.Nanosecond() + t10 := gtime.TimestampNano() fmt.Println(t10 - t9) } diff --git a/.example/net/ghttp/server/session/session.go b/.example/net/ghttp/server/session/session.go index 203ecbace..91cc7ade1 100644 --- a/.example/net/ghttp/server/session/session.go +++ b/.example/net/ghttp/server/session/session.go @@ -10,7 +10,7 @@ func main() { s := g.Server() s.Group("/", func(group *ghttp.RouterGroup) { g.GET("/set", func(r *ghttp.Request) { - r.Session.Set("time", gtime.Second()) + r.Session.Set("time", gtime.Timestamp()) r.Response.Write("ok") }) g.GET("/get", func(r *ghttp.Request) { diff --git a/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_client.go b/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_client.go index e98edc8ac..7ce623e40 100644 --- a/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_client.go +++ b/.example/net/gtcp/pkg_operations/monitor/gtcp_monitor_client.go @@ -27,7 +27,7 @@ func main() { }, MemUsed: 15560320, MemTotal: 16333788, - Time: int(gtime.Second()), + Time: int(gtime.Timestamp()), }) if err != nil { panic(err) diff --git a/.example/os/grpool/goroutine.go b/.example/os/grpool/goroutine.go index f31af0a9d..fc97f88e5 100644 --- a/.example/os/grpool/goroutine.go +++ b/.example/os/grpool/goroutine.go @@ -9,7 +9,7 @@ import ( ) func main() { - start := gtime.Millisecond() + start := gtime.TimestampMilli() wg := sync.WaitGroup{} for i := 0; i < 100000; i++ { wg.Add(1) @@ -19,5 +19,5 @@ func main() { }() } wg.Wait() - fmt.Println("time spent:", gtime.Millisecond()-start) + fmt.Println("time spent:", gtime.TimestampMilli()-start) } diff --git a/.example/os/grpool/grpool.go b/.example/os/grpool/grpool.go index e02776fb8..e067af081 100644 --- a/.example/os/grpool/grpool.go +++ b/.example/os/grpool/grpool.go @@ -10,7 +10,7 @@ import ( ) func main() { - start := gtime.Millisecond() + start := gtime.TimestampMilli() wg := sync.WaitGroup{} for i := 0; i < 100000; i++ { wg.Add(1) @@ -21,5 +21,5 @@ func main() { } wg.Wait() fmt.Println(grpool.Size()) - fmt.Println("time spent:", gtime.Millisecond()-start) + fmt.Println("time spent:", gtime.TimestampMilli()-start) } diff --git a/.example/os/gtime/gtime_func.go b/.example/os/gtime/gtime_func.go index 668e78a69..a7e75aaeb 100644 --- a/.example/os/gtime/gtime_func.go +++ b/.example/os/gtime/gtime_func.go @@ -9,8 +9,8 @@ import ( func main() { fmt.Println("Date :", gtime.Date()) fmt.Println("Datetime :", gtime.Datetime()) - fmt.Println("Second :", gtime.Second()) - fmt.Println("Millisecond:", gtime.Millisecond()) - fmt.Println("Microsecond:", gtime.Microsecond()) - fmt.Println("Nanosecond :", gtime.Nanosecond()) + fmt.Println("Second :", gtime.Timestamp()) + fmt.Println("Millisecond:", gtime.TimestampMilli()) + fmt.Println("Microsecond:", gtime.TimestampMicro()) + fmt.Println("Nanosecond :", gtime.TimestampNano()) } diff --git a/container/gpool/gpool.go b/container/gpool/gpool.go index b1ead9f94..ed9424c10 100644 --- a/container/gpool/gpool.go +++ b/container/gpool/gpool.go @@ -71,7 +71,7 @@ func (p *Pool) Put(value interface{}) { if p.Expire == 0 { item.expire = 0 } else { - item.expire = gtime.Millisecond() + p.Expire + item.expire = gtime.TimestampMilli() + p.Expire } p.list.PushBack(item) } @@ -86,7 +86,7 @@ func (p *Pool) Get() (interface{}, error) { for !p.closed.Val() { if r := p.list.PopFront(); r != nil { f := r.(*poolItem) - if f.expire == 0 || f.expire > gtime.Millisecond() { + if f.expire == 0 || f.expire > gtime.TimestampMilli() { return f.value, nil } } else { @@ -130,7 +130,7 @@ func (p *Pool) checkExpire() { // TODO Do not use Pop and Push mechanism, which is not graceful. if r := p.list.PopFront(); r != nil { item := r.(*poolItem) - if item.expire == 0 || item.expire > gtime.Millisecond() { + if item.expire == 0 || item.expire > gtime.TimestampMilli() { p.list.PushFront(item) break } diff --git a/database/gredis/gredis_unit_test.go b/database/gredis/gredis_unit_test.go index 85b5e8283..4239d0c53 100644 --- a/database/gredis/gredis_unit_test.go +++ b/database/gredis/gredis_unit_test.go @@ -93,7 +93,7 @@ func Test_Conn(t *testing.T) { conn := redis.Conn() defer conn.Close() - key := gconv.String(gtime.Nanosecond()) + key := gconv.String(gtime.TimestampNano()) value := []byte("v") r, err := conn.Do("SET", key, value) gtest.Assert(err, nil) diff --git a/frame/gins/gins_config_test.go b/frame/gins/gins_config_test.go index 6d250a36b..412d4957f 100644 --- a/frame/gins/gins_config_test.go +++ b/frame/gins/gins_config_test.go @@ -112,7 +112,7 @@ test = "v=1" // absolute path gtest.Case(t, func() { - path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.Nanosecond()) + path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.TimestampNano()) file := fmt.Sprintf(`%s/%s`, path, "config.toml") err := gfile.PutContents(file, config) gtest.Assert(err, nil) @@ -126,7 +126,7 @@ test = "v=1" time.Sleep(500 * time.Millisecond) gtest.Case(t, func() { - path := fmt.Sprintf(`%s/%d/config`, gfile.TempDir(), gtime.Nanosecond()) + path := fmt.Sprintf(`%s/%d/config`, gfile.TempDir(), gtime.TimestampNano()) file := fmt.Sprintf(`%s/%s`, path, "config.toml") err := gfile.PutContents(file, config) gtest.Assert(err, nil) @@ -140,7 +140,7 @@ test = "v=1" time.Sleep(500 * time.Millisecond) gtest.Case(t, func() { - path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.Nanosecond()) + path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.TimestampNano()) file := fmt.Sprintf(`%s/%s`, path, "test.toml") err := gfile.PutContents(file, config) gtest.Assert(err, nil) @@ -155,7 +155,7 @@ test = "v=1" time.Sleep(500 * time.Millisecond) gtest.Case(t, func() { - path := fmt.Sprintf(`%s/%d/config`, gfile.TempDir(), gtime.Nanosecond()) + path := fmt.Sprintf(`%s/%d/config`, gfile.TempDir(), gtime.TimestampNano()) file := fmt.Sprintf(`%s/%s`, path, "test.toml") err := gfile.PutContents(file, config) gtest.Assert(err, nil) diff --git a/frame/gins/gins_view_test.go b/frame/gins/gins_view_test.go index 51733f5c5..d156bb398 100644 --- a/frame/gins/gins_view_test.go +++ b/frame/gins/gins_view_test.go @@ -35,7 +35,7 @@ func Test_View(t *testing.T) { gtest.Assert(b, "中国人") }) gtest.Case(t, func() { - path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.Nanosecond()) + path := fmt.Sprintf(`%s/%d`, gfile.TempDir(), gtime.TimestampNano()) tpl := fmt.Sprintf(`%s/%s`, path, "t.tpl") err := gfile.PutContents(tpl, `{{"我是中国人" | substr 2 -1}}`) gtest.Assert(err, nil) diff --git a/i18n/gi18n/gi18n_unit_test.go b/i18n/gi18n/gi18n_unit_test.go index 73976a3b2..36933c981 100644 --- a/i18n/gi18n/gi18n_unit_test.go +++ b/i18n/gi18n/gi18n_unit_test.go @@ -123,7 +123,7 @@ func Test_Instance(t *testing.T) { }) gtest.Case(t, func() { - m := gi18n.Instance(gconv.String(gtime.Nanosecond())) + m := gi18n.Instance(gconv.String(gtime.TimestampNano())) gtest.Assert(m.T("{#hello}{#world}"), "{#hello}{#world}") }) } diff --git a/net/ghttp/ghttp_server_admin_process.go b/net/ghttp/ghttp_server_admin_process.go index 6520625f1..082d513b1 100644 --- a/net/ghttp/ghttp_server_admin_process.go +++ b/net/ghttp/ghttp_server_admin_process.go @@ -43,7 +43,7 @@ type utilAdmin struct{} var serverActionLocker sync.Mutex // (进程级别)用于记录上一次操作的时间(毫秒) -var serverActionLastTime = gtype.NewInt64(gtime.Millisecond()) +var serverActionLastTime = gtype.NewInt64(gtime.TimestampMilli()) // 当前服务进程所处的互斥管理操作状态 var serverProcessStatus = gtype.NewInt() @@ -93,11 +93,11 @@ func checkProcessStatus() error { // 检测当前操作的频繁度 func checkActionFrequence() error { - interval := gtime.Millisecond() - serverActionLastTime.Val() + interval := gtime.TimestampMilli() - serverActionLastTime.Val() if interval < gADMIN_ACTION_INTERVAL_LIMIT { return errors.New(fmt.Sprintf("too frequent action, please retry in %d ms", gADMIN_ACTION_INTERVAL_LIMIT-interval)) } - serverActionLastTime.Set(gtime.Millisecond()) + serverActionLastTime.Set(gtime.TimestampMilli()) return nil } diff --git a/net/ghttp/ghttp_server_cookie.go b/net/ghttp/ghttp_server_cookie.go index 33e4876b0..c279706fd 100644 --- a/net/ghttp/ghttp_server_cookie.go +++ b/net/ghttp/ghttp_server_cookie.go @@ -101,7 +101,7 @@ func (c *Cookie) SetCookie(key, value, domain, path string, maxAge time.Duration isHttpOnly = httpOnly[0] } c.data[key] = CookieItem{ - value, domain, path, gtime.Second() + int64(maxAge.Seconds()), isHttpOnly, + value, domain, path, gtime.Timestamp() + int64(maxAge.Seconds()), isHttpOnly, } } diff --git a/os/gcache/gcache_mem_cache.go b/os/gcache/gcache_mem_cache.go index 73757c32c..c0022fd2b 100644 --- a/os/gcache/gcache_mem_cache.go +++ b/os/gcache/gcache_mem_cache.go @@ -143,7 +143,7 @@ func (c *memCache) doSetWithLockCheck(key interface{}, value interface{}, durati // getInternalExpire returns the expire time with given expire duration in milliseconds. func (c *memCache) getInternalExpire(expire int64) int64 { if expire != 0 { - return gtime.Millisecond() + expire + return gtime.TimestampMilli() + expire } else { return gDEFAULT_MAX_EXPIRE } @@ -179,7 +179,7 @@ func (c *memCache) Get(key interface{}) interface{} { item, ok := c.data[key] c.dataMu.RUnlock() if ok && !item.IsExpired() { - // Adding to LRU history if LRU feature is enbaled. + // Adding to LRU history if LRU feature is enabled. if c.cap > 0 { c.lruGetList.PushBack(key) } @@ -238,7 +238,7 @@ func (c *memCache) Remove(key interface{}) (value interface{}) { c.dataMu.Lock() delete(c.data, key) c.dataMu.Unlock() - c.eventList.PushBack(&memCacheEvent{k: key, e: gtime.Millisecond() - 1000}) + c.eventList.PushBack(&memCacheEvent{k: key, e: gtime.TimestampMilli() - 1000}) } return } @@ -365,7 +365,7 @@ func (c *memCache) syncEventAndClearExpired() { // ======================== // Data Cleaning up. // ======================== - ek := c.makeExpireKey(gtime.Millisecond()) + ek := c.makeExpireKey(gtime.TimestampMilli()) eks := []int64{ek - 1000, ek - 2000, ek - 3000, ek - 4000, ek - 5000} for _, expireTime := range eks { if expireSet := c.getExpireSet(expireTime); expireSet != nil { diff --git a/os/gcache/gcache_mem_cache_item.go b/os/gcache/gcache_mem_cache_item.go index ace5ffb13..a53c673cb 100644 --- a/os/gcache/gcache_mem_cache_item.go +++ b/os/gcache/gcache_mem_cache_item.go @@ -14,7 +14,7 @@ import ( func (item *memCacheItem) 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.Millisecond() { + if item.e >= gtime.TimestampMilli() { return false } return true diff --git a/os/genv/genv_test.go b/os/genv/genv_test.go index 3f33f9cbc..747b0f854 100644 --- a/os/genv/genv_test.go +++ b/os/genv/genv_test.go @@ -24,7 +24,7 @@ func Test_GEnv_All(t *testing.T) { func Test_GEnv_Map(t *testing.T) { gtest.Case(t, func() { - value := gconv.String(gtime.Nanosecond()) + value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := os.Setenv(key, "TEST") gtest.Assert(err, nil) @@ -34,7 +34,7 @@ func Test_GEnv_Map(t *testing.T) { func Test_GEnv_Get(t *testing.T) { gtest.Case(t, func() { - value := gconv.String(gtime.Nanosecond()) + value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := os.Setenv(key, "TEST") gtest.Assert(err, nil) @@ -44,7 +44,7 @@ func Test_GEnv_Get(t *testing.T) { func Test_GEnv_Contains(t *testing.T) { gtest.Case(t, func() { - value := gconv.String(gtime.Nanosecond()) + value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := os.Setenv(key, "TEST") gtest.Assert(err, nil) @@ -55,7 +55,7 @@ func Test_GEnv_Contains(t *testing.T) { func Test_GEnv_Set(t *testing.T) { gtest.Case(t, func() { - value := gconv.String(gtime.Nanosecond()) + value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := genv.Set(key, "TEST") gtest.Assert(err, nil) @@ -76,7 +76,7 @@ func Test_GEnv_Build(t *testing.T) { func Test_GEnv_Remove(t *testing.T) { gtest.Case(t, func() { - value := gconv.String(gtime.Nanosecond()) + value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := os.Setenv(key, "TEST") gtest.Assert(err, nil) diff --git a/os/gfile/gfile_z_test.go b/os/gfile/gfile_z_test.go index 2b9a35768..3e67a46d0 100644 --- a/os/gfile/gfile_z_test.go +++ b/os/gfile/gfile_z_test.go @@ -34,7 +34,7 @@ func Test_IsDir(t *testing.T) { func Test_IsEmpty(t *testing.T) { gtest.Case(t, func() { - path := "/testdir_" + gconv.String(gtime.Nanosecond()) + path := "/testdir_" + gconv.String(gtime.TimestampNano()) createDir(path) defer delTestFiles(path) @@ -42,14 +42,14 @@ func Test_IsEmpty(t *testing.T) { gtest.Assert(gfile.IsEmpty(testpath()+path+gfile.Separator+"test.txt"), true) }) gtest.Case(t, func() { - path := "/testfile_" + gconv.String(gtime.Nanosecond()) + path := "/testfile_" + gconv.String(gtime.TimestampNano()) createTestFile(path, "") defer delTestFiles(path) gtest.Assert(gfile.IsEmpty(testpath()+path), true) }) gtest.Case(t, func() { - path := "/testfile_" + gconv.String(gtime.Nanosecond()) + path := "/testfile_" + gconv.String(gtime.TimestampNano()) createTestFile(path, "1") defer delTestFiles(path) diff --git a/os/gfsnotify/gfsnotify_z_unit_test.go b/os/gfsnotify/gfsnotify_z_unit_test.go index f41f1f944..5c920e682 100644 --- a/os/gfsnotify/gfsnotify_z_unit_test.go +++ b/os/gfsnotify/gfsnotify_z_unit_test.go @@ -21,7 +21,7 @@ import ( func TestWatcher_AddOnce(t *testing.T) { gtest.Case(t, func() { value := gtype.New() - path := gfile.Join(gfile.TempDir(), gconv.String(gtime.Nanosecond())) + path := gfile.Join(gfile.TempDir(), gconv.String(gtime.TimestampNano())) err := gfile.PutContents(path, "init") gtest.Assert(err, nil) defer gfile.Remove(path) @@ -56,8 +56,8 @@ func TestWatcher_AddOnce(t *testing.T) { func TestWatcher_AddRemove(t *testing.T) { gtest.Case(t, func() { - path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond()) - path2 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond()) + "2" + path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano()) + path2 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano()) + "2" gfile.PutContents(path1, "1") defer func() { gfile.Remove(path1) @@ -88,7 +88,7 @@ func TestWatcher_AddRemove(t *testing.T) { }) gtest.Case(t, func() { - path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond()) + path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano()) gfile.PutContents(path1, "1") defer func() { gfile.Remove(path1) @@ -123,7 +123,7 @@ func TestWatcher_AddRemove(t *testing.T) { func TestWatcher_Callback(t *testing.T) { gtest.Case(t, func() { - path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond()) + path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano()) gfile.PutContents(path1, "1") defer func() { gfile.Remove(path1) @@ -150,7 +150,7 @@ func TestWatcher_Callback(t *testing.T) { }) // multiple callbacks gtest.Case(t, func() { - path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.Nanosecond()) + path1 := gfile.TempDir() + gfile.Separator + gconv.String(gtime.TimestampNano()) gfile.PutContents(path1, "1") defer func() { gfile.Remove(path1) diff --git a/os/gsession/gsession.go b/os/gsession/gsession.go index 03c6db025..9e544be5e 100644 --- a/os/gsession/gsession.go +++ b/os/gsession/gsession.go @@ -23,5 +23,5 @@ var ( // NewSessionId creates and returns a new and unique session id string, // the length of which is 18 bytes. func NewSessionId() string { - return strings.ToUpper(strconv.FormatInt(gtime.Nanosecond(), 36) + grand.Str(6)) + return strings.ToUpper(strconv.FormatInt(gtime.TimestampNano(), 36) + grand.Str(6)) } diff --git a/os/gsession/gsession_storage_file.go b/os/gsession/gsession_storage_file.go index a474c1c32..5f30a917c 100644 --- a/os/gsession/gsession_storage_file.go +++ b/os/gsession/gsession_storage_file.go @@ -165,7 +165,7 @@ func (s *StorageFile) GetSession(id string, ttl time.Duration, data *gmap.StrAny content := gfile.GetBytes(path) if len(content) > 8 { timestampMilli := gbinary.DecodeToInt64(content[:8]) - if timestampMilli+ttl.Nanoseconds()/1e6 < gtime.Millisecond() { + if timestampMilli+ttl.Nanoseconds()/1e6 < gtime.TimestampMilli() { return nil, nil } var err error @@ -211,7 +211,7 @@ func (s *StorageFile) SetSession(id string, data *gmap.StrAnyMap, ttl time.Durat return err } defer file.Close() - if _, err = file.Write(gbinary.EncodeInt64(gtime.Millisecond())); err != nil { + if _, err = file.Write(gbinary.EncodeInt64(gtime.TimestampMilli())); err != nil { return err } if _, err = file.Write(content); err != nil { @@ -239,7 +239,7 @@ func (s *StorageFile) doUpdateTTL(id string) error { if err != nil { return err } - if _, err = file.WriteAt(gbinary.EncodeInt64(gtime.Millisecond()), 0); err != nil { + if _, err = file.WriteAt(gbinary.EncodeInt64(gtime.TimestampMilli()), 0); err != nil { return err } return file.Close() diff --git a/os/gtime/gtime_z_bench_test.go b/os/gtime/gtime_z_bench_test.go index 69a37e223..a099e20e7 100644 --- a/os/gtime/gtime_z_bench_test.go +++ b/os/gtime/gtime_z_bench_test.go @@ -14,25 +14,25 @@ import ( func Benchmark_Second(b *testing.B) { for i := 0; i < b.N; i++ { - gtime.Second() + gtime.Timestamp() } } func Benchmark_Millisecond(b *testing.B) { for i := 0; i < b.N; i++ { - gtime.Millisecond() + gtime.TimestampMilli() } } func Benchmark_Microsecond(b *testing.B) { for i := 0; i < b.N; i++ { - gtime.Microsecond() + gtime.TimestampMicro() } } func Benchmark_Nanosecond(b *testing.B) { for i := 0; i < b.N; i++ { - gtime.Nanosecond() + gtime.TimestampNano() } } diff --git a/os/gtime/gtime_z_unit_basic_test.go b/os/gtime/gtime_z_unit_basic_test.go index 7f2023e1f..47c97773d 100644 --- a/os/gtime/gtime_z_unit_basic_test.go +++ b/os/gtime/gtime_z_unit_basic_test.go @@ -23,7 +23,7 @@ func Test_SetTimeZone(t *testing.T) { func Test_Nanosecond(t *testing.T) { gtest.Case(t, func() { - nanos := gtime.Nanosecond() + nanos := gtime.TimestampNano() timeTemp := time.Unix(0, nanos) gtest.Assert(nanos, timeTemp.UnixNano()) }) @@ -31,7 +31,7 @@ func Test_Nanosecond(t *testing.T) { func Test_Microsecond(t *testing.T) { gtest.Case(t, func() { - micros := gtime.Microsecond() + micros := gtime.TimestampMicro() timeTemp := time.Unix(0, micros*1e3) gtest.Assert(micros, timeTemp.UnixNano()/1e3) }) @@ -39,7 +39,7 @@ func Test_Microsecond(t *testing.T) { func Test_Millisecond(t *testing.T) { gtest.Case(t, func() { - millis := gtime.Millisecond() + millis := gtime.TimestampMilli() timeTemp := time.Unix(0, millis*1e6) gtest.Assert(millis, timeTemp.UnixNano()/1e6) }) @@ -47,7 +47,7 @@ func Test_Millisecond(t *testing.T) { func Test_Second(t *testing.T) { gtest.Case(t, func() { - s := gtime.Second() + s := gtime.Timestamp() timeTemp := time.Unix(s, 0) gtest.Assert(s, timeTemp.Unix()) }) diff --git a/os/gview/gview_unit_basic_test.go b/os/gview/gview_unit_basic_test.go index 1b9ef73f8..787b92ff8 100644 --- a/os/gview/gview_unit_basic_test.go +++ b/os/gview/gview_unit_basic_test.go @@ -281,7 +281,7 @@ func Test_HotReload(t *testing.T) { dirPath := gfile.Join( gfile.TempDir(), "testdata", - "template-"+gconv.String(gtime.Nanosecond()), + "template-"+gconv.String(gtime.TimestampNano()), ) defer gfile.Remove(dirPath) filePath := gfile.Join(dirPath, "test.html")