Golang|一个优秀的http请求库-resty

TRY 7,000 1

至少我们曾经在一起过。

来自:一言

相关链接

Github

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())
}

运行截图

Golang|一个优秀的http请求库-resty

发表评论 取消回复
表情 图片 链接 代码

  1. xxx
    xxx Lv 1

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

分享