Skip to content

Repository files navigation

errors

Yum

Go Report Card GitHub Workflow Status License

What is this?

A simple errors package that dynamically prepends the package name.

How to install

Open a terminal and run the following:

$ go get -u github.com/mjwhitta/errors

Usage

Below is a sample usage:

package mypackage

import (
    "os"

    "github.com/mjwhitta/errors"
)

func OpenFileByName(name string) (*os.File, error) {
    var e error
    var f *os.File

    if name == "" {
        return nil, errors.New("no name was provided")
    }

    if f, e = os.Open(name); e != nil {
        return nil, errors.Newf("failed to open %s: %w", name, e)
    }

    return f, nil
}

Links

About

Errors package that prepends the package name.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages