golang 请求接口
// 调用 func CallSearchFillingInfos(UA string,req *request.SearchDocRequest) response.SearchDocResponse { b, err := json.Marshal(req) FillingReq, _ := http.NewRequest( "POST", "https://www.XXX.com/data/api/FinancialNew/SearchFillingInfos", strings.NewReader(string(b))) // 设置user-agent FillingReq.Header.Set("User-Agent", UA) FillingReq.Header.Set("Content-Type","application/json") res, _ := (&http.Client{}).Do(FillingReq) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println("调用接口异常%v", err.Error()) } var SearchDocResponse response.SearchDocResponse if err := json.Unmarshal(body, &SearchDocResponse); err != nil { fmt.Println("json解析错误:",err) return SearchDocResponse } return SearchDocResponse }