3 ms·
I disagree. A nil error in Go is most likely a dev forgetting a check. An unwrap() is a dev explicitly saying this should always contain a value. In fact fixing
by rowanG077 5y ago
I disagree. A nil error in Go is most likely a dev forgetting a check. An unwrap() is a dev explicitly saying this should always contain a value. In fact fixing unwrap is as easy as search for unwrap in your codebase and factoring them all out.
- vaylian 5y ago> An unwrap() is a dev explicitly saying this should always contain a value Isn't expect() supposed to cover that case?
- rowanG077 5y agoNo it's the opposite. Unwrap() means the dev said this will never not be set. Expect() is saying if this value is not available exit the program with this user facing error message.
- ModernMech 5y agoexpect() is like unwrap() but you can give a message as an argument.