登录
首页 >  Golang >  Go问答

Golang中未使用的类型(已定义)

来源:stackoverflow

时间:2024-03-07 18:45:43 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学习网公众号了解相关技术文章。

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>