3 ms·
The biggest difference is in rust you have to handle the error case, but in go you can accidentally ignore it.
by justinsaccount 3y ago
The biggest difference is in rust you have to handle the error case, but in go you can accidentally ignore it.
- philozzzozzz 3y agoNo compiler can force you to handle an error. Rust might force you to access a value. Big. Fucking. Deal.
- mkehrt 3y agoThe point isn't that it forces you to access the error. The point is that it prevents you from accessing an invalid return value.
- meling 3y agoI believe there is a vet check for this. So while the compiler won’t stop you from ignoring errors, it will tell you that you aren’t checking an error. Yes, you can ignore the error with _, but then it isn’t accidental.
- jppittma 3y agoThis seams silly and nitpicks to my. In go, you have to assign the error, and if you assign it you have to use the variable. I've never seen this mistake before in my years of using go.
- nulld3v 3y agoGoing to link my comment here: https://news.ycombinator.com/item?id=36398874 https://news.ycombinator.com/item?id=36398874
- masklinn 3y ago> In go, you have to assign the error, and if you assign it you have to use the variable. Nope. Go errors on dead variables, not on dead stores. And because idiomatic go tends to reassign errors to the same variable if you have multiple error-returning functions in the same scope any one of them being checked will make the compiler happy. You also do not have to assign the error at all, you can just ignore the entire thing.