这个链接https://golang.org/pkg/time/#Unix介绍了func Unix(sec int64, nsec int64) Time函数的签名含义, 还会返回一个time对象。
但是下面的程序中止了错误消息:
14: cannot use now.Unix() (type int64) as type time.Time in assignment`
func main() {
var now time.Time
now = time.Now()
fmt.Println(now)
var secs time.Time
secs = now.Unix()
fmt.Println(secs)
}
以下版本的程序生成输出:
func main() {
var now time.Time
now = time.Now()
fmt.Println(now)
// var secs time.Time
secs := now.Unix()
fmt.Println(secs)
}
2016-04-12 18:20:22.566965512 -0400 EDT
1460499622
这仅仅是文档中的错误吗?