Golang中未使用的类型(已定义)
时间:2024-03-07
浏览:137
作者:佚名
Golang不知道大家是否熟悉?今天我将给大家介绍《Golang中未使用的类型(已定义)》,这篇文章主要会讲到等等知识点,如果你在看完本篇文章后,有更好的建议或者发现哪里有问题,希望大家都能积极评论指出,谢谢!希望我们能一起加油进步!
问题内容
以下结构给出警告:
未使用的类型“device_type_struct”
type device_type_struct struct {
id string `json:"_id"`
brandname string `json:"brandname"`
category string `json:"category"`
firmware string `json:"firmware"`
label string `json:"label,omitempty"`
model string `json:"model"`
supported bool `json:"supported"`
type string `json:"type"`
platform string `json:"platform,omitempty"`
ovrcpro bool `json:"ovrcpro"`
ovrchome bool `json:"ovrchome"`
logtimeseries bool `json:"logtimeseries"`
attributes attributes_struct `json:"attributes"`
}
但是,它的用途是:
var deviceType Device_Type_Struct
err = json.Unmarshal(buf, &deviceType)
if err == nil {
println("Request unmarshalled")
} else {
println("Error unmarshalling request to Device_Type_Struct")
}
insertedId, err := db.UpsertOne("devicetypes", deviceType)
if err != nil {
println("Error upserting document")
success = false
}
这有什么原因吗,还是只是 ide 错误?
解决方案
这只是一个 IDE 错误。重新启动笔记本电脑后,GoLand 不再显示任何错误。
文中关于的知识介绍,希望对你的学习有所帮助!若是受益匪浅,那就动动鼠标收藏这篇《Golang中未使用的类型(已定义)》文章吧,也可关注golang学习网公众号了解相关技术文章。
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
11.20
11.20
11.20
11.20
热门专题
