我很新于Go语言,正在努力理解所有不同类型及其使用方法。我有一个接口,其中包含以下内容(最初来自json文件):
[map[item:electricity transform:{fuelType}] map[transform:{fuelType} item:gas]]
我有以下结构体:
type urlTransform struct {
item string
transform string
}
我不知道如何将接口数据传输到结构体中;我确定这很愚蠢,但我已经尝试了一整天。任何帮助都将不胜感激。
cannot use value (type interface {}) as type []byte in argument to json.Unmarshal: need type assertion
。我尝试了err := json.Unmarshal(data.([]byte), &transforms)
但是现在我得到了panic: interface conversion: interface {} is []interface {}, not []uint8
:( - Katie