News for hackers. Stuff that matters.
Re:Things Go needs more than generics by rowanG077 on Monday October 04, 2021 @04:48AM (#28744518)
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.
Re:Things Go needs more than generics by vaylian on Monday October 04, 2021 @08:30AM (#28745808)
> An unwrap() is a dev explicitly saying this should always contain a value

Isn't expect() supposed to cover that case?

Re:Things Go needs more than generics by rowanG077 on Monday October 04, 2021 @09:09AM (#28746206)
No 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.
Re:Things Go needs more than generics by ModernMech on Monday October 04, 2021 @09:12AM (#28746235)
expect() is like unwrap() but you can give a message as an argument.