Fixes from golangci-lint
This commit is contained in:
parent
e2ac0ad45e
commit
7c425e25cb
15
merr/merr.go
15
merr/merr.go
@ -13,22 +13,10 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/mediocregopher/mediocre-go-lib/v2/mctx"
|
||||
)
|
||||
|
||||
var strBuilderPool = sync.Pool{
|
||||
New: func() interface{} { return new(strings.Builder) },
|
||||
}
|
||||
|
||||
func putStrBuilder(sb *strings.Builder) {
|
||||
sb.Reset()
|
||||
strBuilderPool.Put(sb)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
type annotateKey string
|
||||
|
||||
// Error wraps an error such that contextual and stacktrace information is
|
||||
@ -62,7 +50,7 @@ func (e Error) FullError() string {
|
||||
sb.WriteString(": ")
|
||||
|
||||
// if there's no newlines then print v inline with k
|
||||
if strings.Index(v, "\n") < 0 {
|
||||
if strings.Contains(v, "\n") {
|
||||
sb.WriteString(v)
|
||||
continue
|
||||
}
|
||||
@ -111,6 +99,7 @@ func Wrap(ctx context.Context, err error) error {
|
||||
}
|
||||
|
||||
// New is a shortcut for:
|
||||
//
|
||||
// merr.WrapSkip(ctx, errors.New(str), 1)
|
||||
func New(ctx context.Context, str string) error {
|
||||
return WrapSkip(ctx, errors.New(str), 1)
|
||||
|
@ -9,7 +9,7 @@ package mlog
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -23,7 +23,7 @@ type mlogAnnotation string
|
||||
|
||||
// Null is an instance of Logger which will write all Messages to /dev/null.
|
||||
var Null = NewLogger(&LoggerOpts{
|
||||
MessageHandler: NewMessageHandler(ioutil.Discard),
|
||||
MessageHandler: NewMessageHandler(io.Discard),
|
||||
})
|
||||
|
||||
// Truncate is a helper function to truncate a string to a given size. It will
|
||||
@ -239,7 +239,9 @@ func (l *Logger) Log(msg Message) {
|
||||
}
|
||||
|
||||
if msg.Level.Int() < 0 {
|
||||
l.opts.MessageHandler.Sync()
|
||||
if err := l.opts.MessageHandler.Sync(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user