sTime := time.Now()
defer func() { eTime := time.Now() debug("Success for ", qname, "for", eTime.Sub(sTime)) }() thanks, should be like this Nanosecond() function just return int ( nano second in one second ) On Friday, November 25, 2016 at 4:39:50 PM UTC+8, Peter Wang wrote: > > you should use Sub function > Time include two part. Nanosecond method just return field of nsec. not > nanoseconds since from 1970 > type Time struct { > // sec gives the number of seconds elapsed since > // January 1, year 1 00:00:00 UTC. > sec int64 > // nsec specifies a non-negative nanosecond > // offset within the second named by Seconds. > // It must be in the range [0, 999999999]. > nsec int32 > loc *Location > } > > On Friday, November 25, 2016 at 3:38:23 PM UTC+8, Xu Lei wrote: >> >> >> ...... >> >> sTime := time.Now().Nanosecond() >> >> >> defer func() { >> >> >> eTime := time.Now().Nanosecond() >> >> >> debug("Success for ", qname, "for", (eTime-sTime)/1000000) >> >> >> }() >> >> ...... >> >> >> i got negative value for (eTime - sTime) when defer function calls >> >> is there any thing wrong for this ? >> >> i used to thought that eTime should be greater then sTime >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.