为什么没有位置工作人员在golang time.Equal?

dil*_*ish 3 go

http://golang.org/src/pkg/time/time.go

62  // Equal reports whether t and u represent the same time instant.
63  // Two times can be equal even if they are in different locations.
64  // For example, 6:00 +0200 CEST and 4:00 UTC are Equal.
65  // This comparison is different from using t == u, which also compares
66  // the locations.
67  func (t Time) Equal(u Time) bool {
68      return t.sec == u.sec && t.nsec == u.nsec
69  }
Run Code Online (Sandbox Code Playgroud)

为什么他们不关心t.loc和u.loc?

更新:如果我有2台服务器(不同的位置),我如何判断他们的时间是否完全相同?

Den*_*ret 10

一个Time存储的UTC时间戳.这意味着它不依赖于位置.

时间6:00 +0200 CEST4:00 UTCUTC值相同.他们是完全相同的时刻.

该位置仅用于此时的本地化表示.

文档:

以这种方式更改位置只会改变演示文稿; 它不会及时改变