4 ms·
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 th
by bcgraham 11y ago
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(...)
- jalfresi 11y agoAs 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 :)
- nothrabannosir 11y agoGreat suggestion---I recant my original comment and second this.
- ryanskidmore 11y agoThanks for the suggestion, i'll add something similar to this when i've got a bit of time. Cheers!