Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"os"
"github.com/gemcook/merr"
)
type structError struct {
i int
str string
b bool
}
func (structError) Error() string {
return "structError"
}
type ptrError struct {
i int
str string
b bool
}
func (*ptrError) Error() string {
return "ptrError"
}
func main() {
err := merr.New()
// error interface
err.Append(fmt.Errorf("%w", fmt.Errorf("wrap error")))
// struct
var structErr structError = structError{
i: 1,
str: "error",
b: true,
}
err.Append(structErr)
// ptr
var ptrErr *ptrError = &ptrError{
i: 1,
str: "error",
b: true,
}
err.Append(ptrErr)
merr.SetOutput(os.Stdout)
err.PrettyPrint()
}
Output: Errors[ &fmt.wrapError{ msg: "wrap error", err: &errors.errorString{ s: "wrap error", }, }, merr_test.structError{ i: 1, str: "error", b: true, }, &merr_test.ptrError{ i: 1, str: "error", b: true, }, ]
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResetOutput ¶
func ResetOutput()
func SetNewLine ¶ added in v1.1.0
func SetNewLine(n string)
SetNewLine is a function to set the newline code.
Only "\n" , "\r\n" or "\r" are allowed. If they do not apply, the default value ("\n") is used.
Types ¶
Click to show internal directories.
Click to hide internal directories.