Fix nix builds: go dependencies are awful

This commit is contained in:
bluepython508
2023-11-29 15:41:06 +00:00
parent 0926de2bd8
commit 259f002a99
11 changed files with 355 additions and 124 deletions

27
netforward/buffer.go Normal file
View File

@@ -0,0 +1,27 @@
// From https://github.com/goburrow/netforward
package netforward
import "sync"
const (
bufferSize = 32 * 1024
)
var (
bufferPool = sync.Pool{
New: func() interface{} {
return make([]byte, bufferSize)
},
}
)
func getBuffer() []byte {
return bufferPool.Get().([]byte)
}
func releaseBuffer(b []byte) {
if len(b) != bufferSize {
panic("attempted to release buffer with invalid length")
}
bufferPool.Put(b)
}