Skip to content

Errors package that prepends the package name.

License

Notifications You must be signed in to change notification settings

mjwhitta/errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

errors

Yum

Go Report Card 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

License

Stars

Watchers

Forks