Skip to content

Instantly share code, notes, and snippets.

@jftuga
Created May 30, 2024 13:40
Show Gist options
  • Save jftuga/c96f653b32516425482fc04991cd008b to your computer and use it in GitHub Desktop.
Save jftuga/c96f653b32516425482fc04991cd008b to your computer and use it in GitHub Desktop.
example
package main
import (
"fmt"
"io"
"os"
)
func main() {
var count int64
var total int64
var err error
for {
count, err = io.CopyN(os.Stdout, os.Stdin, 1048576)
if err != nil {
total += count
goto DONE
}
total += count
}
DONE:
_, _ = fmt.Fprintf(os.Stderr, "%d bytes copied.\n", total)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment