Hacker News new | past | comments | ask | show | jobs | submit login

An idea is to include a function in the library called MustNewServer() that panics instead of returning an error. A usability perk of having single return is that the function can be chained, i. e.,

    ws := gowork.MustNewServer(key).AddParams(...)



As much as I hate chaining functions, I do like the idiom of declaring that a function may panic with the 'Must' prefix.

As long as there is an alternative function which returns errors :)


Thanks for the suggestion, i'll add something similar to this when i've got a bit of time. Cheers!


Great suggestion---I recant my original comment and second this.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: