Skip to content

Commit 6d06816

Browse files
committed
Test Go 1.24
1 parent dffb169 commit 6d06816

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
go-version: [1.16.x, 1.17.x]
12+
go-version: [1.16.x, 1.24.x]
1313

1414
steps:
1515
- name: Set up Go

parser.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,24 @@ var FileReaderPool = sync.Pool{
3939
// ByteBufferPool is a pool for temporary byte slices
4040
var ByteBufferPool = sync.Pool{
4141
New: func() interface{} {
42-
// 8KB initial capacity is a good balance
43-
return make([]byte, 0, 8*1024)
42+
slice := make([]byte, 0, 8*1024)
43+
return &slice
4444
},
4545
}
4646

4747
// StringBufferPool is a pool for string slices
4848
var StringBufferPool = sync.Pool{
4949
New: func() interface{} {
50-
return make([]string, 0, 32)
50+
slice := make([]string, 0, 32)
51+
return &slice
5152
},
5253
}
5354

5455
// ExtendedPosPool is a pool for slices of ExtendedPos
5556
var ExtendedPosPool = sync.Pool{
5657
New: func() interface{} {
57-
return make([]ExtendedPos, 0, 8)
58+
slice := make([]ExtendedPos, 0, 8)
59+
return &slice
5860
},
5961
}
6062

@@ -90,7 +92,7 @@ func PutStringBuilder(sb *strings.Builder) {
9092

9193
// GetByteBuffer retrieves a byte buffer from the pool
9294
func GetByteBuffer() []byte {
93-
return ByteBufferPool.Get().([]byte)[:0] // Reset length but keep capacity
95+
return (*ByteBufferPool.Get().(*[]byte))[:0] // Reset length but keep capacity
9496
}
9597

9698
// PutByteBuffer returns a byte buffer to the pool
@@ -101,18 +103,18 @@ func PutByteBuffer(buf []byte) {
101103

102104
// GetStringBuffer retrieves a string slice from the pool
103105
func GetStringBuffer() []string {
104-
return StringBufferPool.Get().([]string)[:0] // Reset length but keep capacity
106+
return (*StringBufferPool.Get().(*[]string))[:0] // Reset length but keep capacity
105107
}
106108

107109
// PutStringBuffer returns a string slice to the pool
108110
func PutStringBuffer(slice []string) {
109111
sliceCopy := make([]string, 0, cap(slice))
110-
StringBufferPool.Put(sliceCopy)
112+
StringBufferPool.Put(&sliceCopy)
111113
}
112114

113115
// GetExtendedPosBuffer retrieves an ExtendedPos slice from the pool
114116
func GetExtendedPosBuffer() []ExtendedPos {
115-
return ExtendedPosPool.Get().([]ExtendedPos)[:0] // Reset length but keep capacity
117+
return (*ExtendedPosPool.Get().(*[]ExtendedPos))[:0] // Reset length but keep capacity
116118
}
117119

118120
// PutExtendedPosBuffer returns an ExtendedPos slice to the pool

0 commit comments

Comments
 (0)