This repository is a collection of small Go programs, exercises, and experiments. Use the topic blocks below to find where a concept lives.
| Folder | Summary |
|---|---|
100_go_mistakes/ |
Collection of small examples based on common Go pitfalls. |
100_go_mistakes/embedding/ |
Embedding vs named fields; mutex exposure; io.WriteCloser embedding. |
100_go_mistakes/embedding/embed/ |
Types used by the embedding example. |
100_go_mistakes/errors/ |
Error wrapping, custom error types, and errors.Join/Is/As usage. |
100_go_mistakes/errors/defer_error/ |
Deferred error handling and error joining. |
100_go_mistakes/init_functions/ |
init ordering and sync.Once alternatives. |
100_go_mistakes/init_functions/main/ |
Main package demonstrating init order. |
100_go_mistakes/init_functions/redis/ |
Sample package with init hook. |
100_go_mistakes/loop_array_pt/ |
Range loop pointer aliasing pitfalls. |
100_go_mistakes/shadowing_variables/ |
Variable shadowing examples and fixes. |
| Folder | Summary |
|---|---|
compositetypes/ |
Entry point for arrays, slices, maps, and structs. |
compositetypes/arrays/ |
Array basics, comparisons, and keyed elements. |
compositetypes/arrays/challenge1/ |
Mood message exercise. |
compositetypes/arrays/digitalclock/ |
ASCII digital clock and digit definitions. |
compositetypes/maps/ |
Map creation, lookup, and deletion patterns. |
compositetypes/maps/maps2/ |
Nested maps/slices and sorting. |
compositetypes/maps/proyect/ |
Regex cleanup and parsing experiment. |
compositetypes/slices/ |
Slice basics, append, capacity, sorting, and filtering. |
compositetypes/slices/bouncingball/ |
Terminal animation using a rune buffer. |
compositetypes/slices/filefinder/ |
Finds empty files and writes their names. |
compositetypes/slices/filefinder/files/ |
Sample files for the filefinder example. |
compositetypes/slices/go1-23-slices-maps/ |
Go 1.23 slices/maps/iter sequence helpers. |
compositetypes/slices/slices2/ |
Backing array and capacity deep dive. |
compositetypes/slices/slices3/ |
Full slice expressions, make/copy, and spinner. |
compositetypes/slices/slicespractice/ |
Slice capacity exercises and memory reporting. |
compositetypes/slices/slicespractice/api/ |
Helpers for large slice allocation and mem stats. |
compositetypes/structs/ |
Struct basics, embedding, and comparisons. |
compositetypes/structs/exercises/ |
CLI exercise with JSON marshaling. |
compositetypes/structs/newlib/ |
Exported vs unexported fields and constructors. |
compositetypes/structs/structs2/ |
Embedded structs, JSON tags, and permissions map. |
| Folder | Summary |
|---|---|
concurrency/ |
Concurrency patterns, channels, and sync primitives. |
concurrency/atomic/ |
Atomic counter example. |
concurrency/bytest/ |
Website checker with tests and benchmarks. |
concurrency/contextpackage/ |
Context usage patterns. |
concurrency/contextpackage/withcancel/ |
Cancelable context and generator. |
concurrency/contextpackage/withdeadline/ |
Deadlines and ctx.Err handling. |
concurrency/contextpackage/withtimeout/ |
HTTP request with context timeout. |
concurrency/contextpackage/withvalue/ |
Context values for request data. |
concurrency/datarace/ |
Data race examples and fixes. |
concurrency/exampleapp/ |
Link checker using channels. |
concurrency/exampleapp/exampleapp2/ |
Buffered channel link checker. |
concurrency/exampleapp/exampleapp3/ |
WaitGroup link checker. |
concurrency/exampleapp/sumarray/ |
Parallel sum of random arrays. |
concurrency/fan_in/ |
Fan-in channel merge example. |
concurrency/goroutines/ |
Goroutine and channel basics. |
concurrency/goroutines/bufferedchannels/ |
Buffered channel behavior. |
concurrency/goroutines/channeldirections/ |
Send-only and receive-only channels. |
concurrency/goroutines/channelownership/ |
Channel ownership pattern and filter. |
concurrency/goroutines/channels/ |
Basic channel send/close semantics. |
concurrency/goroutines/client/ |
TCP client for server demo. |
concurrency/goroutines/closure/ |
Closure capture in goroutines and Fibonacci. |
concurrency/goroutines/rangechannels/ |
Ranging over channels with close. |
concurrency/goroutines/select/ |
Select over multiple channels. |
concurrency/goroutines/server/ |
TCP server that writes responses. |
concurrency/goroutines/timeouts/ |
Timeouts and non-blocking select. |
concurrency/goroutines/waitgroup/ |
WaitGroup usage and worker example. |
concurrency/lgowithtests/ |
Learn Go with Tests website checker. |
concurrency/mutex/ |
Mutex-protected deposit/withdraw example. |
concurrency/pipelines/ |
Generator -> square pipeline example. |
concurrency/pipelines/new_pipe_example/ |
Context-aware pipeline with semaphores and merge. |
concurrency/pipelines/scalepipeline/ |
Fan-out/fan-in pipeline with workers. |
concurrency/syncpool/ |
sync.Pool with bytes.Buffer reuse. |
concurrency/ticker/ |
Placeholder for ticker examples. |
concurrency/timer/ |
time.NewTimer usage and stopping timers. |
concurrency/worker_pool/ |
Worker pool with job queue and results. |
| Folder | Summary |
|---|---|
interfaces/ |
Interface-based store and type assertions. |
interfaces/betteruseofinterfaces/ |
Stringer/sort/json usage with custom types. |
interfaces/emptyinterface/ |
interface{} examples and type assertions. |
interfaces/example/ |
Density interface for metals and gases. |
interfaces/writer/ |
io.Writer example and container/list usage. |
generics/ |
Generic functions and type constraints. |
generics/basics/ |
Bubble sort, map keys, and linked list. |
generics/basics/advanced/ |
Generic map/filter/concat examples. |
generics/basics/advanced/advanced_2/ |
Stringer constraints and joiner pattern. |
generics/basics/advanced/advanced_3/ |
Type sets and aggregate function. |
generics/basics/advanced/advanced_4/ |
Generic vector math. |
| Folder | Summary |
|---|---|
bitsbytesandtypes/ |
Numeric types, conversions, durations, and slice copying. |
closure/ |
Closure example with deferred invocation. |
constants/ |
Constants, typeless values, and iota examples. |
controlflowerrorhandling/ |
Control flow and boolean logic examples. |
controlflowerrorhandling/errorhandling/ |
Error handling, parsing, and switch patterns. |
expressions/ |
Basic expressions, runtime info, and library usage. |
formatedoutput/ |
fmt.Printf formatting examples. |
functional_options/ |
Functional options pattern basics. |
functional_options/better_functional_options/ |
Typed options for server/client configs. |
functions/ |
Structs with slices/maps and function semantics. |
loops/ |
For-loop patterns, tables, and spinner. |
methods/ |
Method receivers on book/game and list usage. |
numbersandstrings/ |
Arithmetic, conversions, and string/rune operations. |
numbersandstrings/weights/ |
Weight type aliases. |
osinput/ |
os.Args input handling examples. |
packages/ |
Multi-file package examples. |
packages/what/ |
A simple multi-file package with shared functions. |
pointers/ |
Pointer basics and passing pointers to functions. |
pointers/compositetypes/ |
Pointers with arrays, slices, maps, and structs. |
pointers/exercises/ |
Pointer exercises. |
pointers/exercises/second/ |
Swap values and pointer addresses. |
pointers/exercises/third/ |
Fixing nil pointer initialization. |
pointers/exercises/fourth/ |
Slice of maps initialization exercise. |
reflect/ |
Reflection examples with tags and dynamic field updates. |
stringbuilder/ |
strings.Builder stub. |
stringdetailed/ |
Runes, Unicode iteration, and formatting. |
stringdetailed/challenge1/ |
Placeholder for string challenge. |
stringdetailed/stringdetailed2/ |
String/byte/rune conversions and UTF-8 decoding. |
usingmodules/ |
Minimal module example. |
variables/ |
Variables, path split, and filtering helpers. |
variables/typeconversion/ |
Type conversion examples. |
exportlib/ |
Tiny library exporting a Go version helper. |
library/ |
Shared helper functions used by examples. |
| Folder | Summary |
|---|---|
config/ |
Terminal configuration files (Alacritty, fish, Starship). |
tempscripts/ |
TOML editing script and sample config. |
| Folder | Summary |
|---|---|
logparser/ |
Parses stdin log lines and prints domain summaries. |
randomproy/ |
Lucky number game and random utilities. |
randomproy/wordfinder/ |
Word lookup using labeled breaks. |
sloglogger/ |
Custom slog handler and misc experiments. |
sloglogger/slogtest/ |
Test-aware slog handler and tests. |
sometest/ |
Third-party helpers (samber/lo, slices). |
sqswatermill/ |
Watermill AWS SQS subscriber example. |