This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // config | |
| c, err := mylib.New(&mylib.Config{ | |
| Username: "uname", | |
| Password: "pw", | |
| }) | |
| // methods | |
| c, err := mylib.New("required") | |
| if err !=nil{ | |
| // ... |
OlderNewer