Basics for Gos
Go basics are the core language elements: basic types, variables, functions with multiple return values, control flow with if, for and switch, and composite types such as arrays, slices and maps. Structs group fields and methods attach behaviour to them, forming the way Go models data without classes.
Stage: Language · Part of the Go roadmap · Last reviewed 19 November 2026
What to learn in Basics
- Declare variables with var and short assignment and know zero values
- Write functions that return multiple values and named results
- Use slices, append and maps, and explain slice capacity
- Define a struct and attach methods with value or pointer receivers
- Use defer to run cleanup when a function returns
Basics interview questions
What is the difference between an array and a slice in Go?
An array has a fixed length that is part of its type. A slice is a flexible view over an underlying array, holding a pointer, length and capacity, and it can grow with append. Most Go code uses slices.
When should a method use a pointer receiver?
Use a pointer receiver when the method must modify the receiver, when the struct is large and copying would be wasteful, or for consistency if any method needs one. Otherwise a value receiver works and the method operates on a copy.
Where Basics fits in the Go roadmap
Basics belongs to the Language stage (beginner level), which takes about 20 hours. Go essentials.