chore: fix linting issues exposed by fixing golangci-lint (#12895)

Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
Jacob Gadikian
2022-08-11 22:00:24 +02:00
committed by GitHub
co-authored by Marko Julien Robert
parent 15b04c2a87
commit 0943a70215
148 changed files with 570 additions and 468 deletions
+9 -10
View File
@@ -11,24 +11,23 @@ of the errors package. If it will be needed my many extensions, please consider
registering it in the errors package. To create a new error instance use Register
function. You must provide a unique, non zero error code and a short description, for example:
var ErrZeroDivision = errors.Register(9241, "zero division")
var ErrZeroDivision = errors.Register(9241, "zero division")
When returning an error, you can attach to it an additional context
information by using Wrap function, for example:
func safeDiv(val, div int) (int, err) {
if div == 0 {
return 0, errors.Wrapf(ErrZeroDivision, "cannot divide %d", val)
func safeDiv(val, div int) (int, err) {
if div == 0 {
return 0, errors.Wrapf(ErrZeroDivision, "cannot divide %d", val)
}
return val / div, nil
}
return val / div, nil
}
The first time an error instance is wrapped a stacktrace is attached as well.
Stacktrace information can be printed using %+v and %v formats.
%s is just the error message
%+v is the full stack trace
%v appends a compressed [filename:line] where the error was created
%s is just the error message
%+v is the full stack trace
%v appends a compressed [filename:line] where the error was created
*/
package errors
+2 -1
View File
@@ -80,7 +80,8 @@ func writeSimpleFrame(s io.Writer, f errors.Frame) {
// %s is just the error message
// %+v is the full stack trace
// %v appends a compressed [filename:line] where the error
// was created
//
// was created
//
// Inspired by https://github.com/pkg/errors/blob/v0.8.1/errors.go#L162-L176
func (e *wrappedError) Format(s fmt.State, verb rune) {