Gopher with MachineGun


"Shooting Requests like a Machine Gun"

View the Project on GitHub parnurzeal/gorequest


GoRequest -- Simplified HTTP client ( inspired by famous SuperAgent lib in Node.js )

Sending request would never been fun and easier than this. It comes with lots of feature:


$ go get


See Go Doc or Go Walker for usage and details.


Drone Build Status Travis Build Status

Why should you use GoRequest?

GoRequest makes thing much more simple for you, making http client more awesome and fun like SuperAgent + golang style usage.

This is what you normally do for a simple GET without GoRequest:

resp, err := http.Get("")

With GoRequest:

request := gorequest.New()
resp, body, errs := request.Get("").End()

Or below if you don't want to reuse it for other requests.

resp, body, errs := gorequest.New().Get("").End()

How about getting control over HTTP client headers, redirect policy, and etc. Things is getting more complicated in golang. You need to create a Client, setting header in different command, ... to do just only one GET

client := &http.Client{
  CheckRedirect: redirectPolicyFunc,

req, err := http.NewRequest("GET", "", nil)

req.Header.Add("If-None-Match", `W/"wyzzy"`)
resp, err := client.Do(req)

Why making things ugly while you can just do as follows:

request := gorequest.New()
resp, body, errs := request.Get("").
  Set("If-None-Match", `W/"wyzzy"`).

DELETE, HEAD, POST, PUT are now supported and can be used the same way as GET:

request := gorequest.New()
resp, body, errs := request.Post("").End()
// PUT -> request.Put("").End()
// DELETE -> request.Delete("").End()
// HEAD -> request.Head("").End()


For a JSON POST with standard libraries, you might need to marshal map data structure to json format, setting header to 'application/json' (and other headers if you need to) and declare http.Client. So, you code become longer and hard to maintain:

m := map[string]interface{}{
  "name": "backy",
  "species": "dog",
mJson, _ := json.Marshal(m)
contentReader := bytes.NewReader(mJson)
req, _ := http.NewRequest("POST", "", contentReader)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Notes","GoRequest is coming!")
client := &http.Client{}
resp, _ := client.Do(req)

Compared to our GoRequest version, JSON is for sure a default. So, it turns out to be just one simple line!:

request := gorequest.New()
resp, body, errs := request.Post("").
  Set("Notes","gorequst is coming!").
  Send(`{"name":"backy", "species":"dog"}`).

Moreover, it also supports struct type. So, you can have a fun Mix & Match sending the different data types for your request:

type BrowserVersionSupport struct {
  Chrome string
  Firefox string
ver := BrowserVersionSupport{ Chrome: "37.0.2041.6", Firefox: "30.0" }
request := gorequest.New()
resp, body, errs := request.Post("")


Moreover, GoRequest also supports callback function. This gives you much more flexibility on using it. You can use it any way to match your own style! Let's see a bit of callback example:

func printStatus(resp gorequest.Response, body string, errs []error){


In the case when you are behind proxy, GoRequest can handle it easily with Proxy func:

request := gorequest.New().Proxy("http://proxy:999")
resp, body, errs:= request.Get("").End()
// To reuse same client with no_proxy, use empty string:
resp, body, errs= request.Proxy("").("").End()


Timeout can be set in any time duration using time package:

request := gorequest.New().Timeout(2*time.Millisecond)
resp, body, errs:= request.Get("").End()



GoRequest is MIT License.