Skip to content

Educational materials and snippets

License

Notifications You must be signed in to change notification settings

mdw-smarty/httpreq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

httpreq

What's wrong with the following function call?

request, err := http.NewRequest(http.MethodGet, "https://www.google.com", nil)

Passing an explicit nil to a function is a design smell. But at this point, any change to that function signature would break the Go compatability promise.

So, herein I present an approach (based on Dave Cheney's excellent "Functional Options for Friendly APIs") to library design that follows the open-closed principle:

"Modules should be closed for modifification, open for extension."

Enjoy!

About

Educational materials and snippets

Resources

License

Stars

Watchers

Forks

Languages