Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 530 Bytes

README.md

File metadata and controls

29 lines (23 loc) · 530 Bytes

blunderguard

A sentinel error package in Go as described by Dave Cheney

Usage

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!