获取 Go 语言中的 Unix 时间戳(当前时间,以秒为单位) [英] Obtaining a Unix Timestamp in Go Language (current time in seconds since epoch)

查看:18
本文介绍了获取 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] = time.Now().Unix()

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

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