我尝试在go lang中解析日期字符串"2014-09-12T11:45:26.371Z".
码
layout := "2014-09-12T11:45:26.371Z"
str := "2014-11-12T11:45:26.371Z"
t, err := time.Parse(layout , str)
Run Code Online (Sandbox Code Playgroud)
解析时间"2014-11-12T11:47:39.489Z":月份超出范围
我收到了这个错误.
如何解析这个日期字符串?
看到这个游乐场片段.
相关代码:
type somethingFuncy func(int) bool
func funcy(i int) bool {
return i%2 == 0
}
var a interface{} = funcy
func main() {
_ = a.(func(int) bool) // Works
fmt.Println("Awesome -- apparently, literally specifying the func signature works.")
_ = a.(somethingFuncy) // Panics
fmt.Println("Darn -- doesn't get here. But somethingFuncy is the same signature as func(int) bool.")
}
Run Code Online (Sandbox Code Playgroud)
第一个演员通过明确声明类型来工作.但第二次演员恐慌.为什么?是否有一种干净的方式来转换为更长的功能签名?