Skip to content

Instantly share code, notes, and snippets.

@deankarn
Created March 31, 2019 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deankarn/b9d0698ed9fdc329cc6f7a446b8f0cea to your computer and use it in GitHub Desktop.
Save deankarn/b9d0698ed9fdc329cc6f7a446b8f0cea to your computer and use it in GitHub Desktop.
package mylib
import "net/http"
// Config contains all library configuration data
type Config struct {
Username string
Password string
}
type Instance struct {
client http.Client
}
// New create a new Instance of mylib
func New(c *Config) (*Instance, error) {
// create an http client where the basic credentials
// are injected automatically into requests.
client, err := // ...
return &Instance{
client: client,
}, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment