The Go source file
We have seen, in Chapter 1, A First Step in Go, some examples of Go programs. In this section, we will examine the Go source file. Let us consider the following source code file (which prints "Hello World"
greetings in different languages):
A typical Go source file, such as the one listed earlier, can be divided into three main sections, illustrated as follows:
The Package Clause:
//1 Package Clause package main
The Import Declaration:
//2 Import Declaration import "fmt" import "math/rand" import "time"
The Source Body:
//3 Source Body var greetings = [][]string{ {"Hello, World!","English"}, ... } func greeting() [] string { ... } func main() { ... }
The package clause indicates the name of the package this source file belongs...