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
Sometimes, users may forget to handle errors. For example,
package something
import"errors"funcReturnsAnError() error {
returnerrors.New("handle me plz")
}
package main
import"something"funcmain()
something.ReturnsAnError() // Forgot to handle error! :(
}
This could be solved by a message showing that this function returns an error they forgot to handle. In cases where the user intentionally does not want to handle the error, they would be forced to make it explicit, using _ (Similar to how staticcheck asks you to make it explicit you meant time.Millisecond when using time.Sleep())
package main
import"something"funcmain()
_:=something.ReturnsAnError() // Forgot to handle error, but it is explicit and we know the user meant to not handle it.
}
The text was updated successfully, but these errors were encountered:
vidhanio
changed the title
Feature Request: Remind to handle functions which return an error.
New Check: Remind to handle functions which return an error.
Dec 25, 2021
Sometimes, users may forget to handle errors. For example,
This could be solved by a message showing that this function returns an error they forgot to handle. In cases where the user intentionally does not want to handle the error, they would be forced to make it explicit, using
_
(Similar to how staticcheck asks you to make it explicit you meanttime.Millisecond
when usingtime.Sleep()
)The text was updated successfully, but these errors were encountered: