Skip to content

asciimoth/putback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

func main() {
	// echo "WORLD" | nc -c 127.0.0.1 3333
	l, err := net.Listen("tcp4", "127.0.0.1:3333")
	if err != nil {
		panic(err)
	}

	for {
		c, err := l.Accept()
		if err != 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

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages