News for hackers. Stuff that matters.
Re:Fourteen Years of Go by usrbinbash on Sunday November 12, 2023 @10:03AM (#38240660)
> it's too easy to forget an error check.

How? What exactly makes this "too easy"?

In regards to a functions error returns, there are exactly two things a caller can do

    func foo() (int, error) {
        // foo code
    }

    // explicitely ignore the error
    foo()
    val, _ := foo()
    
    // handling the error
    val, err := foo()
    _, err := foo()
If I do the latter, I cannot ignore `err`. If I do, the compiler yells at me because there is now an unused value in my code.

If I do the former, then I made the conscious choice that the error doesn't matter to me. Yes, this goes for `foo()` as well, because Go makes it exceedingly clear that errors are just return values, and that call ignores all returns.

Re:Fourteen Years of Go by VBprogrammer on Monday November 13, 2023 @06:50AM (#38249211)
Unless things have changed, if the return is only a single error value then it's possible to overlook capturing it.