August 2019
Beginner to intermediate
798 pages
17h 2m
English
Look at the following Go program named curly.go:
package main
import (
"fmt"
)
func main()
{
fmt.Println("Go has strict rules for curly braces!")
}
Although it looks just fine, if you try to execute it, you will be fairly disappointed, because you will get the following syntax error message and the code will not compile and therefore run:
$ go run curly.go
# command-line-arguments
./curly.go:7:6: missing function body for "main"
./curly.go:8:1: syntax error: unexpected semicolon or newline before {
The official explanation for this error message is that Go requires the use of semicolons as statement terminators in many contexts, and the compiler automatically inserts the required semicolons when ...
Read now
Unlock full access