Skip to content

Instantly share code, notes, and snippets.

@jgrahamc
Created February 10, 2013 15:58
Show Gist options
  • Save jgrahamc/4750014 to your computer and use it in GitHub Desktop.
Save jgrahamc/4750014 to your computer and use it in GitHub Desktop.
func redirect(to string, from *os.File) (err error) {
if out, err := os.Create(name); err == nil {
err = syscall.Dup2(int(out.Fd()), int(from.Fd()))
} else {
err = fmt.Errorf("Unable to create file %s", to)
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment