You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not a bug report, only a question about how go compiles and warns about unused values from function calls (see the play paste for the example).
While go has nothing to do with the programmer not checking for returned values, i found myself easily forgetting to do so, leading to a panic because of a prior error.
When running go run main.go, or any build step, i would like the compiler to warn me about a unused return value from the return_error() function call.
What did you see instead?
The build silently pass.
The text was updated successfully, but these errors were encountered:
The compiler doesn't emit warnings, by design. And it can't emit an error for this kind of issue (definitely not in Go 1, and probably not in Go 2, either). There is the vet tool, but this kind of warning would be very noisy in a lot of cases.
You can use a 3rd party tool, such as errcheck, for this, though. It checks for returned error values that are ignored.
Hello,
This is not a bug report, only a question about how
go
compiles and warns about unused values from function calls (see the play paste for the example).While go has nothing to do with the programmer not checking for returned values, i found myself easily forgetting to do so, leading to a panic because of a prior error.
What about warning about unused returned values?
What version of Go are you using (
go version
)?go1.9 linux/amd64
What did you do?
https://play.golang.org/p/pLQ9_3nGA9
What did you expect to see?
When running
go run main.go
, or any build step, i would like the compiler to warn me about a unused return value from thereturn_error()
function call.What did you see instead?
The build silently pass.
The text was updated successfully, but these errors were encountered: