2 ms·
> That's true if the function doesn't return a value (other than the error) or if it does and the caller also ignores the return value. “Yes” would have done j
by masklinn 3y ago
> That's true if the function doesn't return a value (other than the error) or if it does and the caller also ignores the return value.
“Yes” would have done just fine, especially as this is not uncommon when it comes to IO. But then again who’d do IO in Go right?
> will fail to compile if either i or err are not used following the call.
a, err := G()
if err != nil {
panic(err)
}
i, err := G()
i, err = G()
err = F()
fmt.Println("Got", a, i)
> Maybe the compiler should require the error return to be assigned for F(), that's a bit of a quirk that's under discussion.
It’s not “a bit of a quirk”. The langage only checks for unused variables which is woefully insufficient and unfit for purpose, and has been since the langage was first released.
- cratermoon 3y agoYou seem nice.