shithub: furgit

Download patch

ref: 0f16511df2531d4d1d15434855bdd96b38021836
parent: fd55beb6188350974afd93dfffcef973ebdad6e8
author: Runxi Yu <me@runxiyu.org>
date: Sat Feb 21 15:42:02 EST 2026

bufpool: Fix lints

--- a/internal/bufpool/buffers.go
+++ b/internal/bufpool/buffers.go
@@ -79,12 +79,13 @@
 		newBuf := make([]byte, 0, capHint)
 		return Buffer{buf: newBuf, pool: unpooled}
 	}
+	//nolint:forcetypeassert
 	buf := bufferPools[classIdx].Get().(*[]byte)
 	if cap(*buf) < classCap {
 		*buf = make([]byte, 0, classCap)
 	}
 	slice := (*buf)[:0]
-	return Buffer{buf: slice, pool: poolIndex(classIdx)}
+	return Buffer{buf: slice, pool: poolIndex(classIdx)} //#nosec:G115
 }
 
 // FromOwned constructs a Buffer from a caller-owned byte slice. The resulting
@@ -153,6 +154,7 @@
 	classIdx, classCap, pooled := classFor(needed)
 	var newBuf []byte
 	if pooled {
+		//nolint:forcetypeassert
 		raw := bufferPools[classIdx].Get().(*[]byte)
 		if cap(*raw) < classCap {
 			*raw = make([]byte, 0, classCap)
@@ -165,7 +167,7 @@
 	buf.returnToPool()
 	buf.buf = newBuf
 	if pooled {
-		buf.pool = poolIndex(classIdx)
+		buf.pool = poolIndex(classIdx) //#nosec:G115
 	} else {
 		buf.pool = unpooled
 	}
--- a/internal/bufpool/buffers_test.go
+++ b/internal/bufpool/buffers_test.go
@@ -1,8 +1,11 @@
+//nolint:testpackage
 package bufpool
 
 import "testing"
 
 func TestBorrowBufferResizeAndAppend(t *testing.T) {
+	t.Parallel()
+
 	b := Borrow(1)
 	defer b.Release()
 
@@ -31,6 +34,8 @@
 }
 
 func TestBorrowBufferRelease(t *testing.T) {
+	t.Parallel()
+
 	b := Borrow(DefaultBufferCap / 2)
 	b.Append([]byte("data"))
 	b.Release()
@@ -40,6 +45,8 @@
 }
 
 func TestBorrowUsesLargerPools(t *testing.T) {
+	t.Parallel()
+
 	const request = DefaultBufferCap * 4
 
 	classIdx, classCap, pooled := classFor(request)
@@ -48,7 +55,7 @@
 	}
 
 	b := Borrow(request)
-	if b.pool != poolIndex(classIdx) {
+	if b.pool != poolIndex(classIdx) { //#nosec:G115
 		t.Fatalf("expected pooled buffer in class %d, got %d", classIdx, b.pool)
 	}
 	if cap(b.buf) != classCap {
@@ -58,7 +65,7 @@
 
 	b2 := Borrow(request)
 	defer b2.Release()
-	if b2.pool != poolIndex(classIdx) {
+	if b2.pool != poolIndex(classIdx) { //#nosec:G115
 		t.Fatalf("expected pooled buffer in class %d on reuse, got %d", classIdx, b2.pool)
 	}
 	if cap(b2.buf) != classCap {
@@ -67,6 +74,8 @@
 }
 
 func TestGrowingBufferStaysPooled(t *testing.T) {
+	t.Parallel()
+
 	b := Borrow(DefaultBufferCap)
 	defer b.Release()
 
--