I would do
put it right after resp, err := client.Do(req)
if err!=nil{
// wrap a an err return
return errWrap(err)
}
defer resp.Body.Close()
log.Printf("resp: %+v\n", resp)
if resp.StatusCode != http.StatusOK {
}
Some linter may also suggest you catch the body.Close() err as well
ctx, cancel = context.WithTimeout(context.Background(), client.Timeout)
On Tuesday, October 31, 2017 at 5:52:29 AM UTC-7, 慕希颜 wrote:
>
> Is there a way to add a timeout setting for per request if i declare a
> global var? Because in my case i need different timeout setting for per
> request.