Go - Best practices
summary
Covers concrete Go gotchas and fixes: examples show pass-by-reference for slices and arrays so modifying a slice updates the original backing array; := variable shadowing creates unexpected local variables; slices keep larger capacity and share addresses; len counts bytes so use RuneCountInString for Unicode; ^ is unary bitwise NOT and binary XOR; defer evaluates call arguments immediately and defers execution LIFO; loop-closure goroutines require copying loop vars; use labeled break to exit nested loops and recover only inside deferred functions.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 1:13Pass by reference in Go
- 3:41Variable shadowing
- 5:45Slices memory sharing
- 7:29String length Unicode
- 8:10Logical operators caret
- 9:12Integer overflow loops
- 11:03Labels break loops
- 12:30Defer argument evaluation
- 14:14Defer LIFO order
- 15:18Goroutine closure issue
- 17:06Recovering from panics
- 18:41Closing remarks








