re: API Design: Optional Parameters VIEW POST

FULL DISCUSSION
 

What about a more SOLID solution that is a little bit more compromising

func ProvideOptions(os ...Option) Options  {
    o := Options{}
    for _, option := range os {
        option(&o)
    }
    return o
}

func Get(url string, o Options) (Request, error) {
      // Use immediately
        ....
}

func main()  {
    req, _ := Get("https://example.com", ProvideOptions())

}

Maybe because I like to make the Get function a little bit cleaner and not having to deal with handling Configuration

 
code of conduct - report abuse