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 错误?


万千封印
浏览 161回答 1
1回答

素胚勾勒不出你

这只是一个 IDE 错误。重新启动笔记本电脑后,GoLand 不再显示任何错误。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go