go-resty / resty

Simple HTTP and REST client library for Go
MIT License
10.01k stars 706 forks source link

GenerateCurlCommand() is doesn't work in v2.15.3 #877

Closed Golong-me closed 1 week ago

Golong-me commented 1 week ago

GenerateCurlCommand() is doesn't work in v2.15.3 in 2.14.0. it's work

client := resty.New()
url := "http://localhost:8001/info"
    res, err := client.R().
        EnableTrace().
        Get(url)
    if err != nil {
        t.Error(err)
        return
    }

    //curl is empty string
    t.Log("curl请求命令", res.Request.GenerateCurlCommand())
Golong-me commented 1 week ago

ok,it's update,you should write like here

url := "http://localhost:8001/login"
    res, err := client.R().
        SetDebug(true).
        EnableGenerateCurlOnDebug().
        Get(url)
    if err != nil {
        t.Error(err)
        return
    }
t.Log(res.Request.GenerateCurlCommand())