~nilium/orduniq

d17f16bed07b762aec0eee5b54cc78e199d17b94 — Noel Cower 5 years ago d245f8e
Add input/output buffer size flags

Mainly to help in streams of small amounts of data.
1 files changed, 4 insertions(+), 2 deletions(-)

M uniq.go
M uniq.go => uniq.go +4 -2
@@ 12,6 12,8 @@ import (
func main() {
	log.SetFlags(0)
	log.SetPrefix("orduniq: ")
	bufoutSize := flag.Int("o", 1024, "output buffer size in `bytes`")
	bufinSize := flag.Int("i", 1024, "input buffer size in `bytes`")
	flag.Parse()

	var inputs []io.Reader


@@ 43,9 45,9 @@ func main() {
	}

	hashes := make(map[[sha1.Size]byte]struct{})
	input := bufio.NewReader(io.MultiReader(inputs...))
	input := bufio.NewReaderSize(io.MultiReader(inputs...), *bufinSize)

	bufout := bufio.NewWriter(os.Stdout)
	bufout := bufio.NewWriterSize(os.Stdout, *bufoutSize)
	defer func() {
		ferr := bufout.Flush()
		if ferr != nil {