log/基于golangci-lint修改代码;

This commit is contained in:
2023-04-14 19:35:21 +08:00
parent 1cdffbd6ea
commit 25bea8ca37
9 changed files with 171 additions and 12 deletions

View File

@@ -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)

View File

@@ -5,6 +5,11 @@ import (
"sync"
)
const (
bytesBufferInitialSize = 512
bytesBufferMaximumSize = 4096
)
type BytesBufferPool interface {
Get() *bytes.Buffer
Put(buffer *bytes.Buffer)

View File

@@ -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)