Lesson 1 • Beginner
Introduction to Go 🐹
Discover why Google created Go, what makes it unique among programming languages, and write your very first Go program.
What You'll Learn in This Lesson
- • What Go is and why Google built it
- • Go's design philosophy: simplicity, speed, concurrency
- • Setting up Go and creating a project with
go mod - • Basic syntax, packages, and the
fmtpackage - • Public vs private naming convention
1️⃣ What is Go?
Go (also called Golang) was created at Google in 2009 to solve real problems: slow compile times in C++, complex dependency management, and difficulty writing concurrent programs. Go compiles to a single native binary — no runtime needed — and starts up in milliseconds. It powers Docker, Kubernetes, and most of modern cloud infrastructure.
Try It: Hello Go
Your first Go program and why Go is special
// Your First Go Program — simulated in JavaScript
console.log("=== Hello, Go! ===");
console.log();
// In Go you write:
// package main
// import "fmt"
// func main() {
// fmt.Println("Hello, World!")
// }
console.log("package main");
console.log('import "fmt"');
console.log();
console.log("func main() {");
console.log(' fmt.Println("Hello, World!")');
console.log("}");
console.log();
console.log("Output: Hello, World!");
console.log();
console.log("=== Why Go? ===");
console.log("Cre
...2️⃣ Setting Up Go
Go has excellent tooling built right in. go mod init creates a project, go run executes code, go build compiles a binary, and go fmt formats your code automatically — ending all style debates.
Try It: Setup & Tools
Install Go, create a project, and explore the toolchain
// Setting Up Go
console.log("=== Installing Go ===");
console.log();
console.log("Download from: https://go.dev/dl/");
console.log();
console.log("macOS: brew install go");
console.log("Ubuntu: sudo apt install golang-go");
console.log("Windows: Download .msi installer from go.dev");
console.log();
console.log("=== Verify Installation ===");
console.log(" $ go version");
console.log(" go version go1.22.0 linux/amd64");
console.log();
console.log("=== Go Project Setup ===");
console.lo
...3️⃣ Go Syntax Essentials
Go has only 25 keywords — making it one of the simplest languages to learn. No semicolons, mandatory formatting, and unused imports/variables cause compile errors (keeping code clean by design).
Try It: Syntax Basics
Packages, imports, printing, and naming conventions
// Go Syntax Basics
console.log("=== Go Syntax Overview ===");
console.log();
console.log("// Every Go file starts with a package declaration");
console.log("package main");
console.log();
console.log("// Import single package:");
console.log('import "fmt"');
console.log();
console.log("// Import multiple packages:");
console.log("import (");
console.log(' "fmt"');
console.log(' "strings"');
console.log(' "math"');
console.log(")");
console.log();
console.log("=== Key Syntax Rules ==
...⚠️ Common Mistakes
func main() { on the same line. A newline brace causes a compile error._ as a blank identifier: import _ "fmt".📋 Quick Reference — Go Basics
| Concept | Go Syntax |
|---|---|
| Package | package main |
| Import | import "fmt" |
| fmt.Println("Hello") | |
| Run | go run main.go |
| Build | go build -o app |
| Init module | go mod init name |
🎉 Lesson Complete!
You now understand what Go is and can write your first program. Next, we'll dive into variables and Go's type system!
Sign up for free to track which lessons you've completed and get learning reminders.