01 - What Is Programming?

📋 Jump to Takeaways

A program is a set of instructions that tells a computer what to do. You write those instructions in a programming language, the computer follows them, and something happens. Every app on your phone, every website you visit, every game you play is just a list of instructions someone wrote.

The language we're using is Go. You write instructions in a file, Go turns that file into a program, and you run it.

Installing Go

Download from go.dev/dl and run the installer for your operating system. Open a terminal and verify:

go version

If you see something like go version go1.24.0, you're good. The exact number doesn't matter as long as it's 1.21 or higher.

If you don't have a code editor, grab VS Code. It's free. After installing, open the Extensions panel and search for "Go". Install the official Go extension by the Go team for syntax highlighting, error checking, and auto-formatting.

Your First Program

Create a folder called hello somewhere on your computer. Inside it, create a file called main.go:

package main

import "fmt"

func main() {
	fmt.Println("Hello, World!")
}

Open a terminal, navigate to your hello folder, and run:

go run main.go
Hello, World!

That's a program. Here's what each line does.

What Each Line Means

package main

Every Go file belongs to a package. package main is special. It tells Go "this is a program you can run", not a library someone else imports.

import "fmt"

This loads the fmt package from Go's standard library. fmt stands for "format" and has functions for printing text to the screen.

func main() {

func defines a function, a named block of instructions. main is special: it's where Go starts running your program. Every runnable Go program needs exactly one main function in package main.

	fmt.Println("Hello, World!")

This calls the Println function from the fmt package. Println prints whatever you give it, then moves to a new line. The text inside the quotes is called a string.

How Go Runs Your Code

When you type go run main.go, two things happen:

  1. Go compiles your code. It reads your text file and translates it into something the computer can execute directly. If you made a mistake, it stops here and tells you what's wrong.
  2. Go runs the result. Your instructions execute from top to bottom, starting at func main().

This is different from languages like Python or JavaScript, which read and execute your code line by line. Go checks everything first, then runs it. If you have a typo on line 50, Go catches it before line 1 even runs.

You can also build a standalone program:

go build main.go
./main

go build creates a binary file you can run without Go installed. go run is faster for learning because it compiles and runs in one step.

Making Mistakes

Try removing the closing quote from your string:

func main() {
	fmt.Println("Hello, World!)
}

Run it:

main.go:4:14: newline in string

Go tells you the file, the line number, and what's wrong. This is the compiler catching your mistake before the program runs. You'll see errors like this constantly. They're not failures, they're Go helping you fix things.

Printing and Input

You can call Println as many times as you want. Each call prints on a new line:

fmt.Println("Line 1")
fmt.Println("Line 2")

fmt.Println() with no arguments prints a blank line.

fmt.Scanln() pauses the program and waits for the user to press Enter:

fmt.Println("Press Enter to continue...")
fmt.Scanln()
fmt.Println("Done!")

The program stops at fmt.Scanln() and waits. When you press Enter, it continues.

Key Takeaways

  • A program is a set of instructions a computer follows
  • Go compiles your code first, then runs it. Mistakes are caught before execution
  • Every Go program needs package main and func main()
  • fmt.Println() prints text to the screen
  • fmt.Scanln() pauses the program and waits for the user to press Enter
  • go run main.go compiles and runs in one step
  • go build main.go creates a standalone binary

🚀 Ready to run?

Complete runnable examples for this lesson.

📝 Ready to test your knowledge?

Answer the quiz below to mark this lesson complete.

© 2026 ByteLearn.dev. Free courses for developers. · Privacy