logtail, net/portmapper, wgengine/magicsock: use fmt.Appendf

Fixes #5206

Change-Id: I490bb92e774ce7c044040537e2cd864fcf1dbe5a
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2022-08-03 21:29:11 -07:00
committed by Brad Fitzpatrick
parent 4aa88bc2c0
commit 5381437664
4 changed files with 4 additions and 7 deletions

View File

@@ -5,7 +5,6 @@
package logtail
import (
"bytes"
"errors"
"fmt"
"sync"
@@ -51,9 +50,7 @@ func (m *memBuffer) TryReadLine() ([]byte, error) {
case ent := <-m.pending:
if ent.dropCount > 0 {
m.next = ent.msg
buf := new(bytes.Buffer)
fmt.Fprintf(buf, "----------- %d logs dropped ----------", ent.dropCount)
return buf.Bytes(), nil
return fmt.Appendf(nil, "----------- %d logs dropped ----------", ent.dropCount), nil
}
return ent.msg, nil
default:

View File

@@ -270,7 +270,7 @@ func (l *Logger) drainPending(scratch []byte) (res []byte) {
if err == io.EOF {
break
} else if err != nil {
b = []byte(fmt.Sprintf("reading ringbuffer: %v", err))
b = fmt.Appendf(nil, "reading ringbuffer: %v", err)
batchDone = true
} else if b == nil {
if entries > 0 {