Skip to main content
3 of 4
added 147 characters in body
Dave C
  • 7.9k
  • 18
  • 12

[I'm the original commenter]

My opinion is that full example code should at minimum have a comment of some sort.

E.g. Instead of (Go example):

value, _ := Func1()
Func2(value)

do:

value, err := someFunc()
// check err!!
err = Func2(value)

(in particular, if the reader doesn't go to the documentation, like they should, they may not even realize Func2 returns an error).

By the way, I'm not refering to one line code snippets; I'm referring to fully runnable example code (which is the norm for Go answers here).

Although it's true that some people will just do foolish things and that can't be prevented; we can at least make it a little harder for someone that just doesn't know any better to start getting into bad habits.

The issue is that as much as we can blame the fools that cut-n-paste bad/incomplete examples into their own code, this happens. And then some other SO user has to waste time answering a question by someone that is ignoring errors.

Dave C
  • 7.9k
  • 18
  • 12