What is a program? Reading our first program line by line
What a program, a compiler and a terminal are, every line of the Salom, dunyo program, and how to read an error: for people who never wrote code.
🌐 Oʻzbekcha · Русский · English
Lesson GO-0.01 · Go: 0 → Guru · ▶️ Watch the video on YouTube · 💻 GitHub
This is the full written version of the video lesson: you can learn from it without watching (or hearing) the video. The video itself is in Uzbek.
What you will learn
How does the calculator on your phone know that two plus two is four? Someone wrote down for it, step by step, what to do. In this lesson you too will give a computer a written command for the first time.
The one idea: a program is a list of commands that the computer runs from top to bottom. A compiler translates it into the computer’s language; if even one letter is wrong, it stops and tells you which file and which line.
By the end of the lesson you will be able to:
- read the seven lines of the first Go program in plain words;
- run it in the browser (go.dev/play ) and on your own computer (
go run main.go); - read an error message like
./main.go:6:6piece by piece: which file, which line, which character, what happened.
There are only three new words today:
| Word | Plain meaning | Term |
|---|---|---|
| program | a list of commands for the computer, like a recipe | program |
| compiler | a translator: turns code into the computer’s language | compiler |
| terminal | a window where you type commands to the computer, like a chat | terminal |
Before you start
- Nothing. This is the channel’s first lesson: start here even if you have never written code.
- If you already know Go, go to GO-1.01 · Why does Go exist? What is inside go build.
- There are two ways to run a program. The easiest is in the browser: go.dev/play , nothing to install. The second is on your own computer: we do it step by step in this lesson.
- If you downloaded the course code, all files of this lesson are in the folder
lessons/000-01-birinchi-dastur.
One question before we begin. Until now, how have you given commands to a computer or a phone? Think about it for a moment.
Answer
Most people clicked with a mouse or touched the screen with a finger. Today we give the command in writing. For that we need three words: program (a recipe), compiler (a translator) and terminal (a chat window).
A program is a recipe for the computer
A computer knows nothing by itself: you have to tell it every step. Picture a recipe for plov (an Uzbek rice dish):
- chop the onion;
- fry the carrots;
- add the rice.
The cook follows the list from top to bottom, step by step. A computer also runs a list of commands from top to bottom, line by line. A list of commands written for a computer is called a program.
| In the kitchen | On the computer |
|---|---|
| a recipe (a list of steps) | a program |
| writing the recipe | writing code, that is, the text of the program |
| cooking the plov | running the program |
There are many languages for writing programs. Ours is called Go.
The compiler is a translator
We write code in words a person can read. The computer understands only its own language, made of zeros and ones. So we need a translator in between. The program that translates code into the computer’s language is called a compiler.
code (the text we wrote)
│
▼
compiler (translator) ──► if there is an error: stops and says where
│
▼
0101… (the computer's language)The compiler is very strict. If even one letter in a command is wrong, it does not translate and tells you where the error is. You will see this with your own eyes at the end of the lesson.
The first program, line by line
Here is our first program. It prints Salom, dunyo! (“Hello, world!” in Uzbek). This is the file main.go from the
course folder:
package main
import "fmt"
func main() {
fmt.Println("Salom, dunyo!")
}The file name is main.go. The .go at the end (“dot go”) says this file is Go code. Now let’s read every line:
| Line | Code | What it does |
|---|---|---|
| 1 | package main | package means “a set”. package main means “this is a program you can run”; main is English for “main, the chief one” |
| 2 | (empty) | nothing: left empty to make reading easier |
| 3 | import "fmt" | import means “bring in”. fmt (short for “format”) is a ready toolbox that comes with Go |
| 4 | (empty) | nothing |
| 5 | func main() { | func creates a group of commands; this group is named main. { is the start of the group |
| 6 | fmt.Println("Salom, dunyo!") | prints one line on the screen: Salom, dunyo! |
| 7 | } | the end of the group |
Now each part in more detail.
Line 1: package main. The first word in this file is package, that is, “a set”. package main tells Go “this
file is a program you can run”.
Line 3: import "fmt". import means “bring in”. fmt is a ready toolbox that comes with Go. It has tools for
writing to the screen. Programmers call such a toolbox a package. The toolbox name is written inside quotes,
because quotes (") mark the start and the end of a text.
Line 5: func main() {. The word func creates a group of commands; this group is named main. Programmers call
such a named group a function; you will hear this word a lot in the next lessons. The lines above introduce the
file, and our commands start exactly in this group. The curly braces { and } mark the start and the end of the
group. We will look at the round brackets () after main later: for now, they are always written like this on this
line.
Line 6: fmt.Println("Salom, dunyo!"). This is the most important line. fmt.Println means “the Println tool
from the fmt toolbox”: the dot in the middle means “inside the toolbox”. Println is English print line, that is,
“print one line”. Inside the brackets, between the quotes, is the text that goes to the screen. The indent at the
start of the line is made with the Tab key on the keyboard (Go code is always indented with Tab). We will need
this Tab at the end of the lesson.
In short, the program has four parts:
| # | Part | In plain words |
|---|---|---|
| 1 | package main | this is a program |
| 2 | import "fmt" | a toolbox |
| 3 | func main() { … } | the starting place |
| 4 | fmt.Println(…) | the command that writes to the screen |
Running it in the browser: go.dev/play
The easiest way is the browser. Open go.dev/play on Go’s official site; you install nothing. This is the Go Playground.
- A ready example is in the big window. Delete it.
- Type our seven lines (or copy them from above).
- Press the Run button at the top.
- The result appears at the bottom.
Before you press it, predict: what will appear at the bottom?
A) Salom, dunyo! (without quotes) · B) "Salom, dunyo!" (with the quotes) · C) the whole line 6:
fmt.Println("Salom, dunyo!")
Answer
A. Only Salom, dunyo! appears, without quotes. The quotes are not part of the text; they only marked its
borders. If you chose B, you thought the quotes were part of the text. If you chose C, you thought the
computer copies the code to the screen: in fact it runs the command, and only the text the command prints
reaches the screen.
The bottom part of the Playground shows this:
Salom, dunyo!
Program exited.Program exited. is not something your program wrote. The Playground adds it itself: it means “the program has
finished”.
On your own computer: the terminal
Now let’s run the program on our own computer. For that we need a window where we type commands to the computer. It is like a chat: you type one line and press Enter, and the computer writes the answer below. This window is called a terminal.
┌─ terminal ──────────────────────────────────┐
│ $ go version ← you type │
│ go version go1.26.8 linux/amd64 ← answer │
│ $ █ ← type again │
└──────────────────────────────────────────────┘The sign at the start of the line ($ on this page, C:\Users\…> on Windows) is the terminal’s “type here” sign.
You don’t type it; you type only the command after it.
For example, the command go version tells you Go’s version:
$ go version
go version go1.26.8 linux/amd64go1.26.8 is the version number; yours may be newer, and that is normal. The last word is your type of computer:
yours may say windows/amd64 or darwin/arm64 (Mac).
Installing Go: 4 steps
For this command to work, we first install Go.
- Download the file from go.dev/dl :
.msifor Windows,.pkgfor Mac. - Open the file and follow the prompts (on Windows you keep pressing Next; if it asks for permission, press Yes).
- Open a terminal. On Windows, search for
cmdin the Start menu. On a Mac, press Command + Space and typeTerminal. On Linux (Ubuntu), press Ctrl + Alt + T. - Type
go versionand press Enter. If you see an answer like the one above, Go is installed.
If you see command not found or 'go' is not recognized instead, open the terminal again (or restart the
computer). The installer gives the new setting only to newly opened windows. The detailed steps for Mac and Linux are
in the README file (the explanation file) in the course folder and in the official
installation guide .
Saving the file and opening the terminal in the folder
- Make a new folder on your computer, for example
salom. - Type the seven lines in Notepad or in the free VS Code .
- Save the file in that folder with the name
main.go. In Notepad, set “Save as type” to All files; otherwise the file becomesmain.go.txt. - Open the terminal in that folder. On Windows, open the folder, type
cmdin the address bar at the top and press Enter: the terminal opens right in that folder. In VS Code, choose Terminal → New Terminal from the menu.
go run main.go: translate, then run
Now we type go run main.go in the terminal. It means “run main.go”:
$ go run main.go
Salom, dunyo!The result is the same as in the browser: Salom, dunyo!. This time there is no Program exited. line, because only
the Playground adds it. If you get a “file not found” error, the terminal was opened in another folder (see below,
“Common mistakes”, item 2).
A quick question. The computer does not understand our code, right? Then what happened inside go run?
A) the code ran by itself · B) first a translation, then a run · C) the code was sent to the internet
Answer
B. go run first translates the code into the computer’s language with the compiler, then runs the translation
at once. In short, the computer runs not our text, but its translation. A is impossible: the computer understands
only its own language. C is wrong too: go run does everything on your own computer, without the internet.
main.go (our code)
│ go run
▼
compiler: translates
│
▼
computer's language ──► runs ──► on screen: Salom, dunyo!A mistake on purpose: a small p
Now let’s make a mistake on purpose. In line 6 we change the capital P of Println into a small p. For a person
it is almost the same word. In the course folder this mistake is ready in the file xato/main.go (xato means
“error”):
package main
import "fmt"
func main() {
fmt.println("Salom, dunyo!")
}What will go run main.go do now?
A) Salom, dunyo! appears anyway · B) Go gives an error message · C) Go fixes the error itself and runs
the program
Answer
B. The compiler did not recognise the word written with a small p and did not translate. The program did not
run at all: there is no Salom, dunyo! on the screen, only an error message. If you chose A or C, you thought
the computer understands “roughly”, like a person. The compiler does not guess and does not fix anything: it only
says where the error is.
In the terminal we go into the xato folder (cd is the “go into a folder” command) and run it:
$ cd xato && go run main.go
# command-line-arguments
./main.go:6:6: undefined: fmt.println (but have Println)The first line, # command-line-arguments, is a header: “I translated the files named in the command”. The part we
need is on the second line.
Reading the error message
An error message looks scary, but it gives the exact address of the error. Let’s read it piece by piece:
| Piece | Meaning |
|---|---|
./main.go | the file: ./ means “in this folder”, so main.go in this folder |
6 (first number) | the line: line 6 |
6 (second number) | the character: the 6th character in the line (programmers call this the column) |
undefined: fmt.println | ”not defined”: Go knows no name println in the fmt toolbox |
(but have Println) | a hint: “but there is Println”, that is, with a capital P |
Why is character 6 exactly the small p? Because the Tab at the start of the line also counts as one character:
| Character number | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| In line 6 | Tab | f | m | t | . | p |
The fix
We make the letter capital again (fmt.Println) and run the program again. In the folder with the original
main.go:
$ go run main.go
Salom, dunyo!Salom, dunyo! is back. Two rules follow from this:
- Go tells capital and small letters apart:
Printlnandprintlnare two different names. - When you get an error: first find the file and the line, then read the message. If there are several errors, start with the first one.
Today you read your first program, ran it and read its error. In the next lesson (GO-0.02 · A variable is a label stuck to a value) we will see how a program remembers information.
Common mistakes
1. The idea that “the computer understands roughly”. This is the most common wrong picture in this topic. A
person reads println as Println; the compiler does not. We saw this above, in the section “A mistake on purpose”:
undefined: fmt.println (but have Println). Fix: write the letters as the hint in the message says.
2. The terminal is open in another folder, or the file name is wrong. If you type go run main.go in a folder
without main.go (output taken on Linux):
$ go run main.go
stat main.go: no such file or directoryno such file or directory means “there is no such file or folder”. On Windows the message is different, but the
meaning is the same: the file was not found. Fix: open the terminal in the folder where main.go is. Check that
the file name did not become main.go.txt: in Explorer (the Windows folder window), tick
View → File name extensions to see the full file name.
3. The indent is made with four spaces instead of a Tab. The program still works, but the character number in an
error message comes out different. For example, if we put four spaces instead of the Tab in xato/main.go:
package main
import "fmt"
func main() {
fmt.println("Salom, dunyo!")
}$ go run main.go
# command-line-arguments
./main.go:6:9: undefined: fmt.println (but have Println)Now it is 6:9: the four spaces are characters 1–4, fmt. is 5–8, and p is character 9. Same error, only the
counting is different. Fix: indent with Tab (VS Code does it for you).
4. The quotes became “curly”. Some text editors (programs for writing text), like TextEdit on a Mac, turn "
into “ ”. Go does not recognise them:
package main
import "fmt"
func main() {
fmt.Println(“Salom, dunyo!”)
}$ go run main.go
# command-line-arguments
./main.go:6:14: invalid character U+201C '“' in identifier
./main.go:6:29: syntax error: unexpected ! in argument list; possibly missing comma or )
./main.go:6:30: invalid character U+201D '”' in identifierinvalid character U+201C '“' means “a wrong character: “”. We read the first message: line 6, character 14, which
is exactly the opening quote. The other two lines follow from the same error. Fix: use VS Code, or in TextEdit
choose Format → Make Plain Text and turn off Edit → Substitutions → Smart Quotes.
(Examples 2, 3 and 4 are not in the course folder: they were run in a separate folder. The programs in examples 3
and 4 are changed copies of xato/main.go and main.go.)
Check yourself
Answer first, then open the answer.
1. What is a program?
Answer
A list of commands that the computer runs from top to bottom, line by line, like a recipe.
2. What does a compiler do?
Answer
It translates code into the computer’s language. If there is an error, it does not translate: it stops and says where the error is.
3. What does ./main.go:6:6 mean?
Answer
Line 6, character 6 of the file main.go in this folder.
4. What does this program print?
package main
import "fmt"
func main() {
fmt.Println("2 + 2")
}A) 4 · B) 2 + 2 · C) an error
Answer
B: 2 + 2. Everything inside quotes is text: Println does not calculate it, it writes it to the screen as it
is.
$ go run main.go
2 + 2(This example is not in the course folder; it was run separately.) We will add numbers in GO-0.03.
5. From the start of the lesson: in the Playground, who wrote the line Program exited. after Salom, dunyo!?
Answer
The Playground itself: it means “the program has finished”. Our program wrote only Salom, dunyo!, so in the
terminal, after go run, this line is not there.
Homework
The starter files and answers are in the lesson folder on GitHub: lessons/000-01-birinchi-dastur . Every task also works in go.dev/play .
🟢 Easy (homework/oson/main.go, a copy of the code from the video): instead of Salom, dunyo!, greet yourself
by name, for example Salom, Aziza! (“Hello, Aziza!”).
🟡 Medium: add a second fmt.Println(...) line and print two lines.
🔍 For the curious: delete the last quote in line 6: fmt.Println("Salom, dunyo!). Which line and which character
does the error point to?
➕ One more: write Println as PRINTLN. Which character does the error point to?
Answers: the homework/javoblar/
folder (javoblar means “answers”). Try it yourself first.
Answer
🟢 Only the text inside the quotes changes; the quotes stay:
package main
import "fmt"
func main() {
fmt.Println("Salom, Aziza!")
}🟡 Both lines must be inside the curly braces. The computer runs them from top to bottom, so the first line comes out on top:
package main
import "fmt"
func main() {
fmt.Println("Salom, dunyo!")
fmt.Println("Men Go oʻrganyapman.")
}$ cd homework/javoblar/orta && go run main.go
Salom, dunyo!
Men Go oʻrganyapman.(Men Go oʻrganyapman. means “I am learning Go.”)
🔍 The program without the last quote (this file is not in the course folder; it was run separately):
package main
import "fmt"
func main() {
fmt.Println("Salom, dunyo!)
}$ go run main.go
# command-line-arguments
./main.go:6:29: newline in string
./main.go:6:29: syntax error: unexpected newline in argument list; possibly missing comma or )main.go, line 6, character 29: the end of the line. newline in string means “the line ended inside a text”: the
line ended before the text was closed. The second message follows from the same single error: fix the first one
first.
➕ With PRINTLN (this one is not in the course folder either):
$ go run main.go
# command-line-arguments
./main.go:6:6: undefined: fmt.PRINTLN (but have Println)Character 6 again, but this time it is P, a correct letter. Go points not to the wrong letter but to the start
of the unknown name. In the lesson’s example, the start of the name and the wrong letter were in the same place.
Sources
- A compiler translates source code into machine code (zeros and ones): Harvard CS50x, lecture 1 notes
- The Go language specification (Go spec): Program execution
(
package main,func main), Identifiers , Uniqueness of identifiers (Println≠println) - fmt.Println documentation ·
Get started with Go (
fmtcomes with Go) - Effective Go: Formatting (indent with Tab)
- Go Playground · the text
Program exited.: playground.js - Installing Go: go.dev/doc/install · go.dev/dl
go run: Compile and run Go program- The character number in an error message counts bytes, starting at 1: go/token.Position
- All results were produced with
go1.26.8 linux/amd64on 2026-11-26 (the Go Playground runsgo1.27.4, the texts are the same; in the Playground the file name isprog.go).
Video and code
💻 Code and homework answers on GitHub
Next lesson: GO-0.02 → · All lessons
comments