time.Time 未定义

huangapple go评论87阅读模式
英文:

time.Time undefined

问题

尝试使用类型为time.Time的切片,但它不会将time.Time识别为一种类型。出现错误time.Time未定义(类型int没有Time字段或方法)。我已经在导入部分导入了time,并将其声明为

var alarmTime []time.Time

但是没有成功。

有任何想法吗?

英文:

Trying to use a slice of type time.Time but it won't recognize time.Time as a type. Getting error time.Time undefined (type int has no field or method Time) I have imported time at the top in my imports and declared it as

var alarmTime []time.Time

but with no luck.

Any ideas anyone?

答案1

得分: 13

你显然在你的代码中有一个名为"time"的变量,类型为int

找到它并删除它。

英文:

You obviously have a variable named "time", of type int, somewhere in your code.

Find it and remove it.

答案2

得分: 4

在你的文件顶部(在package ...语句之后)添加import "time"

英文:

add import "time"at the top of your file (after the package ... statement)

huangapple
  • 本文由 发表于 2012年11月7日 19:28:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/13268834.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定