Client.New
Overview
New creates a Client with optional timeout.
If you are coming from Node.js, the closest pattern is axios.create().
Method on Client — call it on a value of that type after constructing or receiving one from a constructor.
Signature
go
func New() *ClientCompare: Node.js · Standard Go · gox
js
axios.create()go
resp, err := http.NewRequestWithContext(ctx, method, url, body)
client.Do(req)go
import "github.com/sahilkhaire/gox/client"
client.New()Example
go
import "github.com/sahilkhaire/gox/client"
client.New()Tips
Pass context.Context as the first argument so cancellation and deadlines propagate correctly.
Standard library alternative
Use the standard library directly:
go
resp, err := http.NewRequestWithContext(ctx, method, url, body)
client.Do(req)