以Go语言获取Unix时间戳(自纪元以来的当前时间) [英] Obtaining a Unix Timestamp in Go Language (current time in seconds since epoch)

查看:1645
本文介绍了以Go语言获取Unix时间戳(自纪元以来的当前时间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码用Go编写,我试图更新以使用最新的每周版本。 (它最后在r60下建成)。除了以下内容外,所有东西都在工作:

I have some code written in Go which I am trying to update to work with the latest weekly builds. (It was last built under r60). Everything is now working except for the following bit:

 if t, _, err := os.Time(); err == nil {
   port[5] = int32(t)
 }

关于如何更新这个版本以适应当前的Go实现的建议?

Any advice on how to update this to work with the current Go implementation?

推荐答案

import "time"
...
port[5] = int32(time.Now().Unix())

这篇关于以Go语言获取Unix时间戳(自纪元以来的当前时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆