August 2019
Beginner to intermediate
798 pages
17h 2m
English
This section will present a technique for sending data to UNIX standard error, which is the UNIX way of differentiating between actual values and error output.
The Go code for illustrating the use of standard error in Go is included in stdERR.go and will be presented in two parts. As writing to standard error requires the use of the file descriptor related to standard error, the Go code of stdERR.go will be based on the Go code of stdOUT.go.
The first part of the program is as follows:
package main
import (
"io"
"os"
)
func main() {
myString := ""
arguments := os.Args
if len(arguments) == 1 {
myString = "Please give me one argument!"
} else {
myString = arguments[1]
}
So far, stdERR.go is almost identical to stdOUT.go ...
Read now
Unlock full access