September 2017
Intermediate to advanced
466 pages
9h 33m
English
This subsection will show you how to send data to standard output in a better way than just using fmt.Println() or any other function from the fmt standard Go package. The Go program will be named writeSTDOUT.go and will be presented to you in three parts.
The first part is the following:
package main import ( "io" "os" )
The second part of writeSTDOUT.go has the following Go code:
func main() {
myString := ""
arguments := os.Args
if len(arguments) == 1 {
myString = "You did not give an argument!"
} else {
myString = arguments[1]
}
The last part of writeSTDOUT.go is the following:
io.WriteString(os.Stdout, myString) io.WriteString(os.Stdout, "\n") }
The only subtle thing is that you need to put your text ...
Read now
Unlock full access