如何在 Go 中将时间戳格式化为 GMT?

How do I format a timestamp as GMT in Go?

我需要使用 HTTP 日期标准 RFC2616 来格式化时间戳。但是,标准说:

All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception.

从一点点挖掘 GMT 和 UTC 不是一回事。在 Go 中是否有将时间戳转换为 GMT 的正确方法?

使用 http.TimeFormat 布局来格式化 HTTP headers 的时间。此布局采用 UTC 位置的时间。

 s := t.UTC().Format(http.TimeFormat)

如果已知时间为 UTC,则可以跳过对 UTC() 的调用:

 s := t.Format(http.TimeFormat)