Unexpected output from time.Time

后端 未结 3 907
栀梦
栀梦 2020-12-10 20:35

I just started to learn Go by following a tutorial video on Udemy, and I tried to print the current time as below

import (
  \"fmt\" 
  \"time\"
)

func main         


        
3条回答
  •  猫巷女王i
    2020-12-10 21:07

    The +08 is the string returned by t.Location().String(). Locations are given a string on creation which is used to identify it. It could be IST, or it can be "+08" or any other string you can think of.

    The m=+0.002000201 is the monotonic clock. It is used for more accurate durations. For more information on Go's monotonic clock implementations, see https://golang.org/pkg/time/#hdr-Monotonic_Clocks.

    As for the reason the monotonic clock shows up in t.String():

    For debugging, the result of t.String does include the monotonic clock reading if present. If t != u because of different monotonic clock readings, that difference will be visible when printing t.String() and u.String().

提交回复
热议问题