Go is a programming language used to build command-line tools, network services, and other applications. A compiler checks your source code and turns it into an executable program. Go is statically typed: the compiler checks which kinds of values your variables and functions can use before the program runs. You will learn those rules through small programs, then combine them into an HTTP API.
You need a terminal, a text editor, and permission to install software on your own computer. No previous Go knowledge is required. If programming is new to you, type the examples, predict the output, and change one thing before moving on. Reading a working program and writing one yourself develop different skills.
Install and verify the toolchain
Use the official installation instructions and choose the installer or archive for your operating system and processor. The toolchain is the collection of tools that builds, runs, formats, and tests Go code. Install a current stable release; the course does not depend on a particular patch version.
On Windows and macOS, follow the installer prompts. On Linux, follow the official archive instructions, including their guidance about replacing an existing installation. Reopen your terminal afterward so it picks up any changes to PATH, the list of directories your shell searches for commands.
Run:
go version
go env GOOS GOARCH
The first command prints your installed Go version. The second prints the operating system and processor architecture targeted by the current configuration. Your output depends on your machine. If the shell cannot find go, fix installation or PATH before continuing; changing your source code cannot repair a missing tool.
Create your first program
Make a new directory for this lesson:
mkdir hello-go
cd hello-go
go mod init example.com/hello-go
This creates go.mod, a file describing your module, the unit used to organize and manage a Go project. The example module path is a local learning name; this command does not publish anything or require you to own that domain.
Save this complete program as main.go:
package main
import "fmt"
func main() {
name := "reader"
fmt.Printf("Hello, %s!\n", name)
fmt.Println("Your Go workspace is ready.")
}
Run it from the directory containing go.mod:
go run .
Expected output:
Hello, reader!
Your Go workspace is ready.
package main identifies an executable package. import "fmt" makes the standard formatting package available. func main() is where execution begins. The short declaration := creates name and lets the compiler infer its type. Printf substitutes the string for %s; \n starts a new line. Println adds a newline automatically. The getting started tutorial explains the same basic project lifecycle.
Build, format, and inspect
Run these commands individually:
go fmt ./...
go vet ./...
go build .
go doc fmt.Printf
Formatting gives your files the standard Go layout. go vet checks for suspicious constructs, such as some mismatches between formatting instructions and arguments. It complements compilation; neither tool proves your program behaves correctly. go build produces an executable here because this directory contains one main package. Run ./hello-go on macOS or Linux, or .\hello-go.exe in Windows PowerShell.
go run . builds and executes the package as a development convenience. go build . leaves a binary you can run separately. The go command reference describes both. You do not need to manually compile each imported standard library package.
Common first mistakes
An unused import or unused local variable prevents compilation. Treat that feedback as help finding unfinished code. Keep the opening brace on the same line as the function declaration, and let the formatter handle spacing. When several files share a package, go run . includes them; go run main.go includes only the named source file.
For lessons 3–10, create a separate directory and module for each example, then save the complete program as main.go and run go run .. Replacing that file is fine. Putting every lesson's main function in one directory creates duplicate declarations.
Exercise: personalize the greeting
Change the program to greet a name you choose and print the number of lessons you plan to complete today. Run, format, and build it again. Check the text yourself rather than treating a successful build as evidence of the right message.
Solution guidance
Replace the body of main with the following; keep the existing package and import:
name := "Asha"
lessons := 2
fmt.Printf("Hello, %s!\n", name)
fmt.Printf("Today's goal: %d lessons.\n", lessons)
%d formats an integer. You should see Hello, Asha! and Today's goal: 2 lessons. on separate lines. Change the goal to another number and verify that the output follows the data.
Next: Go Modules and Packages.

