Skip to content

Instantly share code, notes, and snippets.

@jackdesert
Last active August 29, 2015 14:20
Show Gist options
  • Save jackdesert/a109b0549f19997eda9b to your computer and use it in GitHub Desktop.
Save jackdesert/a109b0549f19997eda9b to your computer and use it in GitHub Desktop.
WriteTo
package main
import (
"bufio"
"io/ioutil"
"log"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
tempFile, err := ioutil.TempFile("/tmp/burnside", "tempfile")
if err != nil {
panic(err)
}
writer := bufio.NewWriter(tempFile)
numBytes, err := reader.WriteTo(writer)
if err != nil {
panic(err)
}
log.Println("numBytes", numBytes)
log.Println("tempFile.Name()", tempFile.Name())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment