标签:
如下函数,将interface变量in转换为int:
func formatTimeStamp(in interface{}, layout string) (out string) { timeStr := in.(int) month, err := time.Parse(layout, string(timeStr)) if err != nil { return time.Now().Format(layout) } return month.Format(layout) }
查看in具体type:
in.(type)
标签:
原文地址:http://www.cnblogs.com/caiya928/p/5591876.html