4 ms·
This 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
by jppittma 3y ago
This 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.