英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论