Gorgo Go for Java Programmers
Bridges Java to Go for working programmers. Covers everything from types and control flow through interfaces, goroutines, and idiomatic Go.
Full book PDF Answer key PDF Read as single page
-
fmt— Revisitedio— The Glue of Go I/Obufio— Buffered I/Oos— Files and the Process Environmentos/exec— Running Subprocessesflag— CLI Flag Parsingtime— Clocks, Durations, and Timerspath/filepath— Cross-Platform Path Manipulationlog/slog— Structured Loggingregexp— Regular Expressionscmpandmaps— Comparison and Map Utilitiesiter— Iteratorsencoding/base64— Base64 Encodingcrypto/randandmath/rand/v2— Random Numberscrypto/sha256,crypto/aes,crypto/cipher— Hashing and Encryption- Try It
- Key Points
- Exercises
-
- The
testing.TType - Table-Driven Tests
t.Helper()t.Cleanup: Teardown the Idiomatic Way- Test Contexts and Artifacts
t.Parallel: Running Tests Concurrently- Deterministic Concurrency with
testing/synctest(Go 1.25) - Benchmarks
- Fuzzing
- Example Tests
- Testing HTTP Handlers with
httptest - Race Detector
- Goroutine Leak Detection
- Integration Tests and Build Tags
- Running Tests
- Try It
- Key Points
- Exercises
- The
-
- Don’t communicate by sharing memory; share memory by communicating
- Concurrency is not parallelism
- The bigger the interface, the weaker the abstraction
- Accept interfaces, return concrete types
- Make the zero value useful
- The empty interface says nothing
- Errors are values
- Don’t just check errors, handle them gracefully
- A little copying is better than a little dependency
- Clear is better than clever
- gofmt’s style is no one’s favorite, yet gofmt is everyone’s favorite
- Cgo is not Go
- Cgo must always be guarded with build constraints
- Syscall must always be guarded with build constraints
- With the unsafe package there are no guarantees
- Reflection is never clear
-
- Formatting
- Comments
- Context
- Copying
- Cryptographic Randomness
- Declaring Empty Slices
- Error Strings
- Don’t Panic
- Examples
- Goroutine Lifetimes
- Handle Errors
- Imports
- Import Blank
- Import Dot
- In-Band Errors
- Indent Error Flow
- Initialisms
- Interfaces
- Line Length
- Mixed Caps
- Named Result Parameters
- Package Comments
- Package Names
- Pass Values
- Receiver Names
- Receiver Type
- Synchronous Functions
- Useful Test Failures
- Variable Names