Documentation ¶
Index ¶
- Variables
- func Assert(cond bool, args ...interface{})
- func Ck(err error, args ...interface{})
- func Debug(msg interface{}, args ...interface{})
- func ErrnoIf(cond bool, errno syscall.Errno, args ...interface{})
- func ExitIf(err, target error, args ...interface{})
- func FormatArgs(args ...interface{}) (msg string)
- func Halt(rc *int, msg *string)
- func Info(msg interface{}, args ...interface{})
- func Pf(format string, args ...interface{}) (n int, err error)
- func Pl(args ...interface{}) (n int, err error)
- func Pprint(in interface{})
- func Return(err *error, args ...interface{})
- func ReturnChan(errc chan error, args ...interface{})
- func SetStdio(stdin io.Reader, stdout, stderr io.Writer)
- func Spprint(in interface{}) string
- func Tassert(t *testing.T, cond bool, args ...interface{})
- func Uerr(msg interface{}, args ...interface{})
- func Unpanic(errno *syscall.Errno, logfunc func(msg string))
- type AdaptErr
Constants ¶
This section is empty.
Variables ¶
var ( Spf = fmt.Sprintf Fpf = fmt.Fprintf )
Make shortcuts for common functions
Allow redirecting stdio
Functions ¶
func Assert ¶
func Assert(cond bool, args ...interface{})
Assert takes a bool and zero or more arguments. If the bool is true, then Assert returns. If the boolean is false, then Assert panics. The panic is of type AdaptErr. The AdaptErr contains the filename and line number of the caller. The first argument is used as a Sprintf() format string. Any remaining arguments are provided to the Sprintf() as values. The Sprintf() result is stored as AdaptErr.msg, to be used later in the AdaptErr.Error() string.
func ErrnoIf ¶ added in v0.0.9
ErrnoIf takes a bool and zero or more arguments. If the bool is false, then ErrnoIf returns. If the boolean is true, then ErrnoIf panics. The panic is of type AdaptErr. The AdaptErr contains the filename and line number of the caller. The first argument must be of type syscall.Errno; the AdaptErr wraps the errno. The next argument is used as a Sprintf() format string. Any remaining arguments are provided to the Sprintf() as values. The Sprintf() result is stored as AdaptErr.msg, to be used later in the AdaptErr.Error() string.
func FormatArgs ¶ added in v0.0.14
func FormatArgs(args ...interface{}) (msg string)
func Pf ¶ added in v0.0.13
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.
func Pl ¶ added in v0.0.13
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.
func Return ¶
func Return(err *error, args ...interface{})
convert panic into returned err see https://github.com/lainio/err2 and https://blog.golang.org/go1.13-errors
func ReturnChan ¶ added in v0.0.10
func ReturnChan(errc chan error, args ...interface{})
convert panic into returned err on channel
Types ¶
type AdaptErr ¶
type AdaptErr struct {
// contains filtered or unexported fields
}
XXX deprecate AdaptErr in favor of Wrap and stackTracer from https://pkg.go.dev/github.com/pkg/errors