Cheatsheet: Go
Last updated 2026-08-15
Variables and Types
Declare variables
Zero values and constants
Arrays and type conversion
Control Flow
if / else
for loop forms
switch
range over collections
Slices and Maps
Create and append to slices
make and copy
Maps
Structs and Methods
Define a struct
Methods
Embedded structs
Interfaces
Define and use an interface
Empty interface replacement
Goroutines and Channels
Start a goroutine
Send and receive on a channel
Buffered channel and range
Error Handling
Return and check errors
Wrap errors
Handle multiple return values
Common stdlib patterns
String formatting with fmt
Marshal JSON
Unmarshal JSON