我想在 go 中以某种格式返回当前时间,我在格式化时间方面没有问题,但是当在 func 中将它作为字符串返回时,我被卡住了:
package main
import (
"fmt"
"time"
)
func getCurrentTime()string{
t := time.Now().Local()
return fmt.Sprintf("%s", t.Format("2006-01-02 15:04:05 +0800"))
}
func main() {
fmt.Println("current Time is:",getCurrentTime)
t := time.Now().Local()
fmt.Println("current Time is:", t.Format("2006-01-02 15:04:05 +0800"))
}
输出是:
current Time is: 0x400c00
current Time is: 2015-01-16 12:45:33 +0800
代替
current Time is: 2015-01-16 12:45:33 +0800
current Time is: 2015-01-16 12:45:33 +0800
这是我所期望的。
 肥皂起泡泡
肥皂起泡泡 
					临摹微笑
 随时随地看视频慕课网APP
随时随地看视频慕课网APP
相关分类