Python's None and JavaScript's undefined both represent "nothing here yet" as a distinct, separate value. Go has no equivalent concept at the variable-declaration level at all — every type has a well-defined zero value, and a freshly declared variable is never in an undefined state.
3 min read
var count int // 0 — not "undefined", not "null", an actual zero
var name string // "" — an empty string, not a missing one
var active bool // false
var price float64 // 0.0Every type in Go has a zero value — the value a variable of that type holds automatically, the instant it's declared, before any explicit assignment. This is a structural difference from Python's None or JavaScript's undefined: those represent "no value was given," a state a program can explicitly check for (if x is None), whereas Go's zero value is a value — 0, "", false — fully usable immediately, with no separate "might not exist yet" state to check for at all.
var age int = "twenty-five" // COMPILE ERROR — cannot use string as intPython and JavaScript would accept wildly mismatched operations at the language level and only fail (or silently produce a wrong result, per JavaScript's coercion lesson) once that specific line actually executes. Go's compiler rejects this particular mistake before the program can even run — a type error here is caught for every code path at compile time, not just the one a test happens to exercise.
package main // every Go file declares which package it belongs to
import "fmt" // standard library import
func main() { // "main" package + "main" function = program entry point
fmt.Println("Hello, Go")
}A Go program is organized into packages — a directory of .go files sharing one package declaration. Unlike Python's module system or JavaScript's ES modules (covered in this curriculum's own lessons), Go's exported vs. unexported visibility rule is built directly into naming convention, not a separate keyword: a function or variable starting with an uppercase letter (ReadFile) is exported and visible to other packages; one starting lowercase (readFile) is private to its own package, enforced by the compiler, not by convention alone.
go.mod — declares the module's name and its dependencies + versions
go.sum — a lockfile of exact dependency checksums (the same role
package-lock.json plays for npm, covered in this
curriculum's Node.js domain)
A go.mod file plays the same role package.json plays for a Node project — it names the module and its dependencies. go.sum is Go's equivalent of a lockfile, recording exact checksums for every dependency so a build is reproducible — directly analogous to the lockfile-integrity concept Web Security's own dependency-vulnerabilities lesson already covered for npm.
A function that returns early without explicitly setting a result still returns something well-defined (the zero value), not an undefined or null value a caller has to separately guard against. This removes an entire category of bug this curriculum has already named in other languages — JavaScript's undefined is not a function class of runtime error simply has no direct equivalent for Go's basic types, because there's no "nothing was ever assigned" state for the type system to fail to catch.
Check your understanding
A quick comprehension check — not tracked, not graded, just for you.
1. What is a zero value in Go?
2. How does Go determine whether an identifier is exported from a package?
3. What role does go.sum play in a Go project?
Go