blunderguard

package module
v0.0.0-...-401cd5c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2022 License: MIT Imports: 0 Imported by: 13

README

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!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error string

func (Error) Error

func (e Error) Error() string

Error implements the golang standard library error interface. This allows us to declare errors as constants

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL