Go
Go (Golang) cheat sheet covering syntax, goroutines, channels, interfaces, error handling, and concurrency patterns with examples.
Setup & Basics
Getting started with Go
Installation & Setup
Installing Go and setting up development environment
Basic Syntax
Go program structure and syntax
Data Types & Structures
Go data types, arrays, slices, maps, and structs
Arrays & Slices
Working with arrays and slices
Maps
Working with maps (hash tables)
Structs
Defining and using structs
Struct Embedding
Composition via embedding structs and interfaces
Pointers
Working with pointers and memory addresses
Pointers
Pointer basics, dereferencing, and nil pointers
Control Flow
Conditionals, loops, and control structures
Conditionals
If statements and switch cases
Loops
For loops and iterations
Functions
Functions, methods, and closures
Functions
Function declaration and usage
Methods
Methods on types and interfaces
Closures
Anonymous functions and closures
Interfaces
Interface types and polymorphism
Interfaces
Defining and implementing interfaces
Type Assertions & Switches
Extract concrete types from interfaces
Generics
Type parameters and constraints
Generics
Generic functions and types with type parameters
Concurrency
Goroutines, channels, and synchronization
Goroutines
Concurrent execution with goroutines
Channels
Communication between goroutines
Select Statement
Multiplex channel operations with select
Sync Primitives
Mutex, WaitGroup, and Once for synchronization
Error Handling
Error handling patterns and best practices
Error Handling
Working with errors in Go
Defer, Panic & Recover
Deferred execution, panics, and recovery
String Formatting
fmt package verbs and string operations
fmt Verbs & Formatting
Printf verbs and string formatting functions
Context
Cancellation, timeouts, and request-scoped values
Context
Cancellation, timeouts, and passing request-scoped data
JSON
Encoding and decoding JSON data
JSON Encoding & Decoding
Marshal, Unmarshal, and struct tags for JSON
HTTP Server & Client
Building HTTP servers and making requests
HTTP Server & Client
net/http server handlers and HTTP client requests
Testing
Writing and running tests
Testing
Unit tests and benchmarks
Packages & Modules
Package management and module system
Packages & Imports
Organizing code with packages