exit

package module
v0.0.0-...-aae6259 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: ISC Imports: 2 Imported by: 5 modules, 33 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Nifty error handling for Golang

Go Report Card GolangCI

This library provides helper methods to dry up repetitive boilerplate around error checking in Golang.

Instead of:

import "log"

if err != nil {
  log.Fatal(err)
}

you can write:

import "github.com/Originate/exit"

exit.If(err)

The IfWrap and IfWrapf functions wrap the given error into the given error message using errors.Wrap and errors.Wrapf:

exit.IfWrap(err, "something went wrong")
exit.IfWrapf(err, "%s", message)

This makes the most sense for critical errors in Go-based CLI tools, but could be useful elsewhere.

Installation

go get github.com/Originate/exit

A gofix tool to change all compatible usages is available at exitfix.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func If

func If(err error)

If runs log.Fatal with the given error if the given error exists.

func IfWrap

func IfWrap(err error, message string)

IfWrap runs log.Fatal with the given error wrapped in the given message if the error exists.

func IfWrapf

func IfWrapf(err error, format string, formatArgs ...interface{})

IfWrapf runs log.Fatal with the given error wrapped in the given message if the error exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

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