AnatomyOf

Anatomy of a Go file

example.go
1package main
2
3import "fmt"
4
5type Greeting struct {
6 Text string
7}
8
9func (g Greeting) Shout() string {
10 return g.Text + "!"
11}
12
13func main() {
14 g := Greeting{Text: "hello"}
15 fmt.Println(g.Shout()) // no exceptions were harmed in this call
16}
Go is a statically typed, compiled programming language designed for simplicity, concurrency, and performance.