Standard library / net/http/httputil
httputil.BufferPool
Interface with Get and Put for temporary response-copy buffers. A pool implementation must allow concurrent use when shared; do not expose residual data to unrelated callers. Expected stdout: '16\n'.
Formal Syntax & Structure
go syntaxgo
type BufferPool interface { Get() []byte Put([]byte)}Working Example
Example Snippetgo
package main
import ( "fmt" "net/http/httputil")
func main() { var p httputil.BufferPool = &pool{}; b := p.Get(); fmt.Println(len(b)); p.Put(b) }
type pool struct{}
func (*pool) Get() []byte { return make([]byte, 16) }func (*pool) Put([]byte) {}func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}