A minimal library with wrappers for common I/O interfaces, adding the ability to return read bytes back to the stream for subsequent reading.
Minimal hello X example:
package main
import (
"fmt""io""net""github.com/asciimoth/putback"
)
funcmain() {
// echo "WORLD" | nc -c 127.0.0.1 3333l, err:=net.Listen("tcp4", "127.0.0.1:3333")
iferr!=nil {
panic(err)
}
for {
c, err:=l.Accept()
iferr!=nil {
panic(err)
}
c=putback.WrapConn(c, []byte("hello "), nil)
b, _:=io.ReadAll(c)
fmt.Println(string(b))
}
}Files in this repository are distributed under the CC0 license.
To the extent possible under law,
ASCIIMoth
has waived all copyright and related or neighboring rights to
putback.
