1. What is whitespace?
We can group newlines, spaces and tabs as whitespaces. These are invisible characters, mostly ignored by Go, but used
by developers to make programs easier to read.
2. What is a comment? What are the two ways of writing a comment?
Comments are extra information added by the developers that ususally explains the source code. There are 2 types of
comment styles in go:
- Single line: Using the characters
//
at the beginning of the comment - Multiple lines: Using the characters
/*
to start a comment and*/
to end it
3. Our program began with package main
. What would the files in the fmt
package begin with?
package fmt
4. We used the Println
function defined in the fmt
package. If we wanted to use the Exit
function from the os
package what would we need to do?
First of we we would need to import that package:
import "os"
And then we could call the Exit
function like this:
os.Exit()
5. Modify the program we wrote so that instead of printing Hello World
it prints Hello, my name is
followed by your name.
package main
import "fmt"
func main() {
fmt.Println("Hello, my name is Robert")
}