From a7354d2d084003e4122d6e69f7e5ab594fd117b2 Mon Sep 17 00:00:00 2001 From: astaxie Date: Sat, 9 Sep 2017 06:29:38 +0800 Subject: [PATCH] Revert "should use time.Since instead of time.Now().Sub" --- cache/memory.go | 2 +- context/param/options.go | 2 +- context/param/parsers_test.go | 2 +- orm/orm_log.go | 2 +- parser.go | 2 +- toolbox/profile.go | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cache/memory.go b/cache/memory.go index 784dbecb..57e868cf 100644 --- a/cache/memory.go +++ b/cache/memory.go @@ -38,7 +38,7 @@ func (mi *MemoryItem) isExpire() bool { if mi.lifespan == 0 { return false } - return time.Since(mi.createdTime) > mi.lifespan + return time.Now().Sub(mi.createdTime) > mi.lifespan } // MemoryCache is Memory cache adapter. diff --git a/context/param/options.go b/context/param/options.go index 3d5ba013..58bdc3d0 100644 --- a/context/param/options.go +++ b/context/param/options.go @@ -7,7 +7,7 @@ import ( // MethodParamOption defines a func which apply options on a MethodParam type MethodParamOption func(*MethodParam) -// IsRequired indicates that this param is required and can not be omitted from the http request +// IsRequired indicates that this param is required and can not be ommited from the http request var IsRequired MethodParamOption = func(p *MethodParam) { p.required = true } diff --git a/context/param/parsers_test.go b/context/param/parsers_test.go index 7065a28e..b946ba08 100644 --- a/context/param/parsers_test.go +++ b/context/param/parsers_test.go @@ -75,7 +75,7 @@ func checkParser(def testDefinition, t *testing.T, methodParam ...MethodParam) { } convResult, err := safeConvert(reflect.ValueOf(result), toType) if err != nil { - t.Errorf("Conversion error for %v. from value: %v, toType: %v, error: %v", def.strValue, result, toType, err) + t.Errorf("Convertion error for %v. from value: %v, toType: %v, error: %v", def.strValue, result, toType, err) return } if !reflect.DeepEqual(convResult.Interface(), def.expectedValue) { diff --git a/orm/orm_log.go b/orm/orm_log.go index 915bfd2d..26c73f9e 100644 --- a/orm/orm_log.go +++ b/orm/orm_log.go @@ -36,7 +36,7 @@ func NewLog(out io.Writer) *Log { } func debugLogQueies(alias *alias, operaton, query string, t time.Time, err error, args ...interface{}) { - sub := time.Since(t) / 1e5 + sub := time.Now().Sub(t) / 1e5 elsp := float64(int(sub)) / 10.0 flag := " OK" if err != nil { diff --git a/parser.go b/parser.go index 1933c6c6..f787fd5c 100644 --- a/parser.go +++ b/parser.go @@ -227,7 +227,7 @@ func parseComment(lines []*ast.Comment) (pc *parsedComment, err error) { } // direct copy from bee\g_docs.go -// analysis params return []string +// analisys params return []string // @Param query form string true "The email for login" // [query form string true "The email for login"] func getparams(str string) []string { diff --git a/toolbox/profile.go b/toolbox/profile.go index 944ec645..06e40ede 100644 --- a/toolbox/profile.go +++ b/toolbox/profile.go @@ -106,7 +106,7 @@ func printGC(memStats *runtime.MemStats, gcstats *debug.GCStats, w io.Writer) { if gcstats.NumGC > 0 { lastPause := gcstats.Pause[0] - elapsed := time.Since(startTime) + elapsed := time.Now().Sub(startTime) overhead := float64(gcstats.PauseTotal) / float64(elapsed) * 100 allocatedRate := float64(memStats.TotalAlloc) / elapsed.Seconds() @@ -123,7 +123,7 @@ func printGC(memStats *runtime.MemStats, gcstats *debug.GCStats, w io.Writer) { toS(gcstats.PauseQuantiles[99])) } else { // while GC has disabled - elapsed := time.Since(startTime) + elapsed := time.Now().Sub(startTime) allocatedRate := float64(memStats.TotalAlloc) / elapsed.Seconds() fmt.Fprintf(w, "Alloc:%s Sys:%s Alloc(Rate):%s/s\n",