Skip to content

Instantly share code, notes, and snippets.

@jackdesert
Created May 6, 2015 20:30
Show Gist options
  • Save jackdesert/6dc9d3487543e2e0c770 to your computer and use it in GitHub Desktop.
Save jackdesert/6dc9d3487543e2e0c770 to your computer and use it in GitHub Desktop.
write From STDIN to File
package main
import (
"io"
"io/ioutil"
"log"
"os"
)
func main() {
tempFile, err := ioutil.TempFile("/tmp/burnside", "tempfile")
bytesWritten, err := io.Copy(tempFile, os.Stdin)
if err != nil {
panic(err)
}
log.Println("bytesWritten", bytesWritten)
log.Println("tempFile.Name()", tempFile.Name())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment