log/基于golangci-lint修改代码;
This commit is contained in:
@@ -60,7 +60,7 @@ func newConfig(opts ...Option) *config {
|
||||
opt.apply(cfg)
|
||||
}
|
||||
if !cfg.hasPool {
|
||||
cfg.bytesBufferPool = NewBytesBufferPool(512, 4096)
|
||||
cfg.bytesBufferPool = NewBytesBufferPool(bytesBufferInitialSize, bytesBufferMaximumSize)
|
||||
}
|
||||
if cfg.output == nil {
|
||||
cfg.output = NewSyncWriter(os.Stderr)
|
||||
|
||||
@@ -5,6 +5,11 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
bytesBufferInitialSize = 512
|
||||
bytesBufferMaximumSize = 4096
|
||||
)
|
||||
|
||||
type BytesBufferPool interface {
|
||||
Get() *bytes.Buffer
|
||||
Put(buffer *bytes.Buffer)
|
||||
|
||||
@@ -18,7 +18,7 @@ type syncWriter struct {
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
func (w *syncWriter) Write(p []byte) (n int, err error) {
|
||||
func (w *syncWriter) Write(p []byte) (int, error) {
|
||||
w.lock.Lock()
|
||||
defer w.lock.Unlock()
|
||||
return w.writer.Write(p)
|
||||
|
||||
Reference in New Issue
Block a user