至少我们曾经在一起过。
来自:一言
相关链接
resty库比go提供的http库更优秀,更安全好用。
代码示例
package main
import (
"crypto/tls"
"fmt"
"github.com/go-resty/resty/v2"
"log"
"time"
)
func main() {
client := resty.New().SetTimeout(3 * time.Second).SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true}) //忽略https证书错误,设置超时时间
resp, err := client.R().EnableTrace().Get("https://www.nctry.com/t.php")
if err != nil {
log.Println(err)
}
str := resp.Body()
body := string(str)
fmt.Println(body)
fmt.Println(resp.StatusCode())
}
运行截图
本文作者为TRY,转载请注明。

感谢分享,挺好的,就是生成的exe有点大接近7m。