Skip to content

Commit

Permalink
Revert "should use time.Since instead of time.Now().Sub"
Browse files Browse the repository at this point in the history
  • Loading branch information
astaxie committed Sep 8, 2017
1 parent 07a9a2d commit a7354d2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cache/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion context/param/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion context/param/parsers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion orm/orm_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions toolbox/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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",
Expand Down

0 comments on commit a7354d2

Please sign in to comment.