Go Introduction

Go · Lesson 1 of 32 6 min read Updated

Go is a small, fast and friendly programming language made for building reliable software, especially programs that run on servers. Tools you may have heard of, such as Docker and Kubernetes, are written in Go, and many Indian start-ups use it for payment systems, delivery tracking and backend APIs.

In this lesson you will learn what Go is, where it came from, what makes it different from languages like Python and Java, and you will read your first Go program. This course teaches Go 1.27, the current release.

What is Go?

Go (often called Golang, after its old website golang.org) is a general-purpose programming language. Three engineers at Google, Robert Griesemer, Rob Pike and Ken Thompson, started designing it in 2007. It was released as open source in 2009, and Go 1.0 arrived in March 2012.

They wanted a language that compiles quickly, runs fast, is easy to read, and makes it simple to use all the cores of a modern processor. Here are the main features:

  • Compiled: the go tool turns your source code into a single executable file (a program you can run directly). There is no separate runtime to install on the server.
  • Statically typed: every variable has a type, such as int or string, that is checked before the program runs. Many mistakes are caught early.
  • Garbage collected: Go frees memory you no longer use automatically, so you do not call free() as in C.
  • Built-in concurrency: goroutines and channels let a program do many things at once, such as serving thousands of web requests.
  • Small language: Go has only 25 keywords. There are no classes and no inheritance; you use structs, methods and interfaces instead.

Your first look at Go code

Here is a complete Go program. Do not worry about every word yet; you will write and run it yourself in Your First Go Program.

Go
package main

import "fmt"

func main() {
	fmt.Println("Namaste from Go!")
	fmt.Println("2 + 3 =", 2+3)
}
Output
Namaste from Go!
2 + 3 = 5

Every Go file starts with a package line. A program that you run must use package main and have a function called main, which is where the program starts. The import "fmt" line brings in the standard fmt package, which prints text. fmt.Println prints its arguments with spaces between them and moves to a new line.

Notice two things. Go code is indented with tabs, and there are no semicolons at the ends of lines. The compiler adds them for you behind the scenes.

Where is Go used?

Go is strongest on the server side and in tools that developers use every day:

AreaExamples
Cloud and containersDocker, Kubernetes, Terraform
Web APIs and microservicesPayment gateways, ride and food delivery backends
Command-line toolsThe GitHub CLI gh, Hugo (a website generator)
Networking and monitoringPrometheus, proxy servers

Go is not the usual choice for mobile apps, games or data science; Kotlin, Swift, C++ and Python are more common there. Go shines when you need a fast, simple program that handles many network connections and is easy to deploy.

How Go compares with other languages

A short program shows the difference in feel. This one adds up the marks of a student and is fully typed:

Go
package main

import "fmt"

func total(marks []int) int {
	sum := 0
	for _, m := range marks {
		sum += m
	}
	return sum
}

func main() {
	priya := []int{78, 92, 85}
	fmt.Println("Priya's total:", total(priya))
}
Output
Priya's total: 255

Compared with Python, Go asks you to state types ([]int means "a list of whole numbers", int after the brackets is the return type), but in return the compiler catches type mistakes and the program runs much faster. Compared with Java, Go has far less ceremony: no class wrapper, no public static void, and the whole program builds into one file in about a second.

What you need to start

You need only three things:

  1. The Go toolchain from go.dev (covered in Install Go & Set Up VS Code).
  2. A code editor. VS Code with the official Go extension is a popular free choice.
  3. A terminal, such as PowerShell on Windows or the Terminal app on Linux and macOS.

You will type commands like these many times in this course:

Terminal
go version
go run .
Output
go version go1.27.3 windows/amd64
Namaste from Go!

The first command shows which Go version is installed and on which system. The second compiles and runs the program in the current folder. The exact version and system on your computer may differ.

Common mistakes

  • Searching for "Go" alone. The word is too common. Search for "golang" or "go.dev" to find Go answers.
  • Expecting classes. Go has no class keyword. Beginners from Java try to force class hierarchies; Go uses small structs and interfaces instead, which you will learn later.
  • Using spaces for indentation. Go code uses tabs. The gofmt tool fixes this automatically, so let your editor run it on save.

Key points

  • Go is a compiled, statically typed, garbage-collected language created at Google and released in 2009.
  • Go 1.27 (August 2026) is the current version; new versions arrive every February and August.
  • A runnable program has package main and a func main() where execution starts.
  • Go is popular for web servers, cloud tools and command-line programs.
  • Go keeps the language small: 25 keywords, no classes, built-in concurrency.

Exercise

Write down, in your own words, three differences between Go and a language you already know (Python, Java, C or JavaScript). Then change the second example so it adds up Rohan's marks, 66, 71 and 80, and predict what it prints.

Show solution

Possible differences: Go is compiled to one executable file; Go checks types before running; Go has goroutines for concurrency and no classes.

Go
func main() {
	rohan := []int{66, 71, 80}
	fmt.Println("Rohan's total:", total(rohan))
}
Output
Rohan's total: 217

Only the slice values and the label change; the total function works for any list of marks.

Quick Quiz

1. Which statement about Go is true?

2. Where does a Go program start running?

3. How often is a new major Go release published?

4. What does Go use instead of classes?

Learn Go with a mentor

Free lessons get you started. Our Programming & Software Development training adds real projects and code reviews from working developers.

  • Project-based learning
  • Mentor code reviews
  • Free counselling call