Skip to content

Instantly share code, notes, and snippets.

View deankarn's full-sized avatar
That's it I'm getting 100 cups of coffee starting now.

Dean Karn deankarn

That's it I'm getting 100 cups of coffee starting now.
View GitHub Profile
package mylib
import "net/http"
// New create a new Instance of mylib
func New(someAlwaysRequiredValue string, options ...func(*Instance) error) (*Instance, error) {
return &Instance{
client: new(http.Client), // default no auth client
}, nil
}
package mylib
import "net/http"
// New create a new Instance of mylib
func New(someAlwaysRequiredValue string) (*Builder, error) {
return &Builder{
// some nice sane defaults if necessary
}, nil
}
// config
c, err := mylib.New(&mylib.Config{
Username: "uname",
Password: "pw",
})
// methods
c, err := mylib.New("required")
if err !=nil{
// ...