The Compilation Process

Go Program Structure

We'll go over this all later in more detail, but to sate your curiosity:

1

package main

package main lets the Go compiler know that we want this code to compile and run as a standalone program, as opposed to being a library that's imported by other programs.

2

import "fmt"

import "fmt" imports the fmt (formatting) packagearrow-up-right from the standard libraryarrow-up-right. It allows us to use fmt.Println to print to the console.

3

func main()

func main() defines the main function, the entry point for a Go program.

Two Kinds of Errors

Generally speaking, there are two kinds of errors in programming:

  1. Compilation errors. Occur when code is compiled. It's generally better to have compilation errors because they'll never accidentally make it into production. You can't ship a program with a compiler error because the resulting executable won't even be created.

  2. Runtime errors. Occur when a program is running. These are generally worse because they can cause your program to crash or behave unexpectedly.

Last updated