A structured, self-learning repository for mastering Go (Golang) from fundamentals to production-ready patterns. This project combines detailed documentation, practical code examples, and professional engineering practices.
inspired by Tech With Tim: https://www.youtube.com/watch?v=V-lI7AmusGs
twt_go is an educational resource designed to take you from Go beginner to confident backend developer. Each topic includes:
- Markdown documentation explaining concepts clearly
- Runnable Go examples demonstrating real-world usage
- Best practices and production engineering patterns
- Progressive complexity β start simple, build advanced skills
- Language Fundamentals β syntax, types, operators, control flow
- Advanced Features β generics, interfaces, error handling
- Concurrency β goroutines, channels, synchronization, thread-safe patterns
- Best Practices β clean code, performance optimization, memory management
- Production Patterns β real-world engineering practices for scalable systems
twt_go/
βββ cheatsheets
β βββ basics.md
β βββ concurrency.md
β βββ data_structures.md
β βββ error_handling.md
β βββ functions_interfaces.md
β βββ generics.md
βββ docs
β βββ arithmetic_ops
β β βββ arithmetic_ops.md
β βββ bits_bytes
β β βββ bits_bytes_and_signed_binaries.md
β βββ conditions_and_conditionals
β β βββ conditions_and_conditionals.md
β βββ data_types
β β βββ data_types.md
β βββ err_handling
β β βββ err_handling.md
β βββ fmtrs
β β βββ fmtrs.md
β βββ generics
β β βββ generics.md
β βββ imp_assign
β β βββ imp_assign.md
β βββ intro
β β βββ intro.md
β βββ ints
β β βββ int_types.md
β βββ loops
β β βββ loops.md
β βββ thd_con
β βββ 'thd_ con.md'
βββ projects
β βββ 01-cli-task-manager.md
β βββ 02-url-health-checker.md
β βββ 03-kv-store.md
β βββ 04-concurrent-grep.md
β βββ 05-distributed-work-queue.md
βββ README.md
βββ src
β βββ arithmetic_ops
β β βββ arithmetic_ops.go
β βββ conditions_and_conditionals
β β βββ comparison_ops.go
β β βββ flt.go
β β βββ if_else.go
β β βββ if_else_multi.go
β β βββ if_stmt.go
β β βββ nested_if.go
β β βββ nkd_switch.go
β β βββ switch_stmt.go
β βββ data_types_and_structures
β β βββ arrays.go
β β βββ basic_data_types.go
β β βββ interfaces.go
β β βββ maps.go
β β βββ pointers.go
β β βββ slice.go
β β βββ struct_slice_combo.go
β β βββ structs.go
β βββ err_handling
β β βββ basic_error.go
β β βββ create_errors.go
β β βββ defer_cleanup.go
β β βββ error_checking.go
β β βββ error_wrapping.go
β β βββ if_error_pattern.go
β β βββ inline_error.go
β βββ fmtrs
β β βββ fmtrs.go
β βββ generics
β β βββ constraint_generic.go
β β βββ contains_generic.go
β β βββ generic_function.go
β β βββ identity_generic.go
β β βββ pair_generic.go
β β βββ stack_generic.go
β βββ imp_assign
β β βββ imp_assign.go
β βββ int_types
β β βββ int_types.go
β βββ intro
β β βββ hello_world.go
β βββ loops
β β βββ break.go
β β βββ continue.go
β β βββ for_loop.go
β β βββ inf_loop.go
β β βββ map_range_loop.go
β β βββ slice_array_range_loop.go
β β βββ str_range_loop.go
β β βββ while_loop.go
β βββ thd_con
β βββ buffer_channel.go
β βββ channels.go
β βββ con_demo.go
β βββ gorountines.go
β βββ mutex.go
β βββ select.go
β βββ waitgroup.go
βββ tips
βββ 01-clean-code.md
βββ 02-performance.md
βββ 03-concurrency.md
βββ 04-memory.md
βββ 05-profiling.md
βββ 06-compiler-optimization.md
- Go 1.21+ (Download)
- A text editor or IDE (VS Code, GoLand, etc.)
- Terminal access
go versionNavigate to any example file and run it:
# Example: Run the hello world program
cd src/intro
go run hello_world.go
# Example: Run data types examples
cd src/data_types_and_structures
go run basic_data_types.go
# Example: Run concurrency examples
cd src/thd_con
go run goroutines.goTo compile all examples:
go build -v ./...Start here if you're new to Go or programming.
- Introduction β What is Go? Why use it?
- Data Types β Primitives, composite types
- Arithmetic Operations β Operators and math
- Bits & Bytes β Binary representation
- Integer Types β int8, int16, int32, int64, uint variants
- Conditions & Conditionals β if/else, switch
- Loops β for, while, range patterns
Build practical skills with Go's unique features.
- Implicit Assignment β Type inference, short declarations
- Formatters β String formatting and output
- Error Handling β Error patterns and strategies
- Data Structures in Depth β Arrays, slices, maps, structs, pointers, interfaces
Leverage Go's powerful advanced capabilities.
- Generics β Type parameters and generic programming (Go 1.18+)
- Threading & Concurrency β Goroutines, channels, synchronization
Apply best practices used in real-world systems.
- Clean Code β Single responsibility, return early, testability
- Performance β Allocations, GC pressure, benchmarking
- Concurrency Patterns β Goroutine lifecycle, ownership, deadlock prevention
- Memory Management β Pointer safety, heap vs. stack
- Profiling β pprof, flame graphs, optimization workflows
- Compiler Optimization β Inlining, bounds checking, optimizations
Apply everything you've learned by building functional applications.
- CLI Task Manager (Beginner)
- Concurrent URL Health Checker (Intermediate)
- In-Memory KV Store with TTL (Intermediate/Advanced)
- Concurrent File Search Tool (Advanced)
- Distributed Work Queue (Advanced)
| Topic | Location | Focus |
|---|---|---|
| Variables & Types | data_types/ |
Type system, inference, declarations |
| Control Flow | conditions_and_conditionals/ |
if/else, switch, pattern matching |
| Loops | loops/ |
for, range, break, continue |
| Functions | src/ examples |
Declaration, parameters, return values |
| Structs & Methods | data_types_and_structures/ |
Composition, method receivers |
| Interfaces | data_types_and_structures/ |
Polymorphism, duck typing |
| Error Handling | err_handling/ |
Error types, wrapping, patterns |
| Generics | generics/ |
Type parameters, constraints |
| Topic | Location | Learn |
|---|---|---|
| Goroutines | thd_con/goroutines.go |
Lightweight threads |
| Channels | thd_con/channels.go |
Communication between goroutines |
| Buffered Channels | thd_con/buffer_channel.go |
Channel buffering strategies |
| Select | thd_con/select.go |
Multiplexing channels |
| Mutex | thd_con/mutex.go |
Shared state synchronization |
| WaitGroup | thd_con/waitgroup.go |
Synchronization barriers |
| Practice | File | Takeaway |
|---|---|---|
| Single Responsibility | tips/01-clean-code.md |
Functions do one thing well |
| Memory Efficiency | tips/02-performance.md |
Reduce allocations, understand GC |
| Goroutine Safety | tips/03-concurrency.md |
Always manage goroutine lifecycle |
| Memory Safety | tips/04-memory.md |
Proper pointer usage, escape analysis |
| Performance Measurement | tips/05-profiling.md |
Profile before optimizing |
| Compiler Behavior | tips/06-compiler-optimization.md |
Understand what the compiler does |
Each topic has a markdown file in docs/. Read the explanation before looking at code.
# Example
cat docs/data_types/data_types.mdDon't just read codeβrun it, modify it, break it, and see what happens.
cd src/loops
go run for_loop.go
# Then edit for_loop.go and experimentFormat your code and catch common mistakes:
go fmt ./...
go vet ./...After each concept, write a small program combining what you learned. This reinforces knowledge.
Use the performance tips to measure your code:
go test -bench=. -benchmem ./...
go tool pprofLook at real Go projects on GitHub to see how professionals write code.
cd src/<topic>
go run <file>.gogo test -v ./...go build -o myapp ./cmd/main.gogofmt -w .go vet ./...go run <file> # Run a Go file
go build ./... # Build all packages
go test ./... # Run all tests
go fmt ./... # Format code
go vet ./... # Static analysis
go mod tidy # Clean dependencies
go version # Check Go version
go env # View Go environment| Concept | Note |
|---|---|
| Type System | Statically typed, compiled, type inference |
| Memory | Garbage collected, pointers available, escape analysis |
| Concurrency | Goroutines (cheap), channels (communication), select |
| Error Handling | Explicit error returns, no exceptions |
| Methods | Can be on any type, receiver syntax |
| Interfaces | Implicit satisfaction, no explicit "implements" |
| Package Visibility | Capitalization determines public/private |
This learning repository aims to:
β
Provide a structured path from beginner to intermediate Go developer
β
Combine theory (docs) with practice (code examples)
β
Teach production-quality Go engineering practices
β
Emphasize concurrencyβGo's defining feature
β
Include performance and memory considerations
β
Show real-world patterns and anti-patterns
Learn Go's unique approach to error handling without exceptions:
- Creating custom errors
- Error wrapping and inspection
- Deferred cleanup
- Inline error checking patterns
Files: docs/err_handling/, src/err_handling/
Master Go's lightweight concurrency model:
- Goroutines vs. threads
- Channel communication patterns
- Synchronization primitives (mutex, waitgroup)
- Avoiding deadlocks and race conditions
Files: docs/thd_con/, src/thd_con/
Use type parameters for reusable, type-safe code (Go 1.18+):
- Generic functions
- Generic types and constraints
- Practical generic patterns
Files: docs/generics/, src/generics/
- Keep notes as you learn new concepts
- Write your own examples for each topic
- Build small projects combining multiple concepts
- Refactor your code using the clean code tips
- Profile your code to understand performance
- Official Go Documentation: golang.org/doc
- Effective Go: golang.org/doc/effective_go
- Go by Example: gobyexample.com
- Go Code Review Comments: github.com/golang/go/wiki/CodeReviewComments
- Standard Library: pkg.go.dev/std
π Structured Learning β Topics progress from simple to complex
π» Runnable Code β Every example can be executed immediately
π Best Practices β Learn how professionals write Go
β‘ Performance Focus β Understand memory, GC, and optimization
π Concurrency-First β Deep dive into Go's superpower
π Well Documented β Clear explanations for every concept
This is a self-learning resource. Use it at your own pace:
- Spend as much time as needed on each topic
- Revisit topics as you grow more experienced
- Use the tips section to improve code quality over time
- Build real projects to reinforce learning
Happy Learning! π
Last Updated: April 2026
Go Version: 1.21+
Status: Active Learning Repository