Hacker News new | past | comments | ask | show | jobs | submit login

I'm sorry, but that's not true: http://play.golang.org/p/PiMXQkKOef



So it appears you're right. For things for which you don't care about any value returned this is the case. The reason I haven't run into this is for the most part things that can error, they also return a value that matters. You can't use the return value without doing something with the error.

http://play.golang.org/p/yreUbxx5Vv

So it appears that there is a loophole for things that can error and purely used for side effects.


This is true, you can drop all return values. However, a lot of functions return a value and an error. If you want to access the value, you need to assign the error to something too. And if you don't then use that error, the compiler will complain about it.

For simply dropping all return values on the ground, there are linters that will complain for you: https://github.com/kisielk/errcheck




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: