As the previous recipe describes, each process has stdin, a stdout and stderr file descriptors. The standard approach is the use of stdout as a process output and stderr as process error output. As these are the file descriptors, the destination where the data is written could be anything, from the console to the socket. This recipe will show you how to write the stdout and stderr.
Writing standard output and error
How to do it...
- Open the console and create the folder chapter05/recipe02.
- Navigate to the directory.
- Create the stdouterr.go file with the following content:
package main
import (
"fmt"
"io"
"os"
)
func main() {
...