func getPrice() ([]byte, error) {
    url := "https://www.goldapi.io/api/XAU/CNY"
    method := "GET"

    client := &http.Client{}
    req, err := http.NewRequest(method, url, nil)

    if err != nil {
        return nil, err
    }
    //change your token
    req.Header.Add("x-access-token", "goldapi-55555555555555-io")

    res, err := client.Do(req)
    if err != nil {
        return nil, err
    }
    defer res.Body.Close()

    body, err := io.ReadAll(res.Body)
    if err != nil {
        return nil, err
    }
    return body, nil

}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code