Categorygithub.com/stevegt/goadapt
modulepackage
0.7.0
Repository: https://github.com/stevegt/goadapt.git
Documentation: pkg.go.dev

# README

goadapt

The Ck/Return pattern from this package can be used to replace the common if err != nil {return err} boilerplate. See examples/ck-return.go for usage.

  • Allows shorter, more readable code.
  • Provides more descriptive error messages.
  • Includes file name and line number in error strings by default.
  • Allows optional per-error and per-function annotations.
  • Allows optional format strings for annotations.

Inspired in part by Dave Cheney's https://github.com/pkg/errors and Harri Lainio's https://github.com/lainio/err2.

This package includes several other possibly-useful functions, including Assert(), Debug(), and Pprint(), as well as a few shortcut vars for common fmt functions:

    Pl  = fmt.Println
    Pf  = fmt.Printf
    Spf = fmt.Sprintf
    Fpf = fmt.Fprintf

Docs are admittedly still thin -- see ./examples here and elsewhere on github for now.

TODO

  • add more doc comments
  • integrate examples into test cases
  • add more examples for full coverage

# Functions

Assert takes a bool and zero or more arguments.
No description provided by the author
No description provided by the author
ErrnoIf takes a bool and zero or more arguments.
No description provided by the author
No description provided by the author
convert panic into returned rc and msg.
No description provided by the author
Pf is a shortcut for fmt.Printf(), but it also allows a caller to redirect stdout by first setting goadapt.Stdout to the desired io.Writer.
Pl is a shortcut for fmt.Println(), but it also allows a caller to redirect stdout by first setting goadapt.Stdout to the desired io.Writer.
No description provided by the author
convert panic into returned err see https://github.com/lainio/err2 and https://blog.golang.org/go1.13-errors.
convert panic into returned err on channel.
SetStdio allows a caller to redirect stdin, stdout, and stderr.
No description provided by the author
No description provided by the author
No description provided by the author
Unpanic converts a panic into a syscall.Errno and a message.

# Variables

Make shortcuts for common functions.
Make shortcuts for common functions.
Allow redirecting stdio.
Allow redirecting stdio.
Allow redirecting stdio.

# Structs

XXX deprecate AdaptErr in favor of Wrap and stackTracer from https://pkg.go.dev/github.com/pkg/errors.