Fundamentals

Why and How of Go

The big picture.

Where is Go Exactly Used?

Go dominates the Cloud and Backend world. If you interact with the cloud, you are using Go.

  • Infrastructure & Tools: Docker, Kubernetes, Terraform, and Prometheus were all written in Go.
  • Microservices & APIs: Companies like Uber, Twitch, and Netflix use Go for their heavy-lifting backend services because it handles thousands of concurrent requests smoothly without eating up server memory.
  • CLI Tools: Because Go is so fast to start up, it's perfect for Command Line Interfaces (like the GitHub CLI).

Go is compiled and statically typed. It might take a few extra seconds to write the types, but the compiler catches most of your errors before the code ever runs.

Go compiles your entire application into a single, standalone binary executable file. It includes everything it needs to run. You just drop that one file onto an empty Linux server (or into a tiny "scratch" Docker container), execute it, and it runs instantly. No runtime or dependencies needed on the server!

Project Structure & Starting a Project

In Go, we use Modules to track our project.

Standard workflow to start a new project from your terminal:

Initialize the module

Terminal
go mod init github.com/yourusername/myapp

This creates a go.mod file, which is exactly like Python's requirements.txt or Node's package.json.

Always make the module name in your go.mod file match the exact URL where the code is actually hosted.

Create your entry point

Create a file named main.go.

Run the code (for development):

Terminal
go run main.go

This compiles and runs your code on the fly.

Build the code (for production):

Terminal
go build

This spits out the magical standalone binary file we talked about.

go build (without arguments) builds the entire module/package defined in go.mod.

If you haven’t initialized a module, Go won’t know what to build and may throw an error.

You can also build a specific file directly:

Terminal
go build main.go

This compiles only that file and does not require a module.

Key idea:

  • go build → builds the project (module/package)
  • go build <file.go> → builds a single file
Copyright © 2026