A sentinel error package in Go as described by Dave Cheney
Blunderguard is very simple
import (
"fmt"
bg "github.com/SSSOC-CAN/blunderguard"
)
const (
ErrInvalidAction = bg.Error("invalid action")
)
func DoSomething() error {
return ErrInvalidAction
}
func main() {
err := DoSomething()
if err == ErrInvalidAction {
fmt.Println("There you go")
}
}
Now your errors are immutable, fungible and constants. Enjoy!