package qweather import ( "encoding/json" "io" "net/http" ) // 获取天气 func Get(location_id int, weather_type_name string, dev bool) (json.RawMessage, error) { // 生成url url, err := makeURL(dev, location_id, weather_type_name) if err != nil { return nil, err } // 发送请求, 获取数据 resp, err := http.Get(url) if err != nil { return nil, err } defer resp.Body.Close() // 读取数据 body, err := io.ReadAll(resp.Body) if err != nil { return nil, err } // 返回数据 return body, nil }