Skip to content

Repository files navigation

putback

A minimal library with wrappers for common I/O interfaces, adding the ability to return read bytes back to the stream for subsequent reading.

Split example:
asciicast

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))
}
}

License

Files in this repository are distributed under the CC0 license.

CC0
To the extent possible under law, ASCIIMoth has waived all copyright and related or neighboring rights to putback.

About

A minimal library with wrappers for common I/O interfaces, adding the ability to return read bytes back to the stream for subsequent reading.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages