我是围棋新手。我正在使用天气 API。我已经注释掉了导致错误的部分。我看到其他几个链接也有类似的问题,但是它们似乎都没有在 JSON 字符串中间包含数组。我确信有一种方法可以用切片定义结构。我似乎无法获得允许它的语法。这是我被困住的地方:
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
// WeatherData struct to collect data from the API call
type WeatherData struct {
Wind Wind
Sys Sys
// Weather Weather
Name string `json:"name"`
}
////////////// ERROR when unmarshalling this struct /////////
// Weather provides basic weather info
// type Weather struct {
// ID int `json:"id"`
// Descrip string `json:"description"`
// Icon string `json:"icon"`
// }
/////////////////////////////////////////////////////////////
// Sys includes sunrise, sunset, country, etc.
type …Run Code Online (Sandbox Code Playgroud)