Go Intermediate: Interfaces, Concurrency, and Services
This course is for developers who can already write standalone Go programs and now need services that compose cleanly, handle concurrency safely, and behave predictably when dependencies stall. You start with consumer-side interfaces, typed-nil pitfalls, streaming io.Reader and io.Writer pipelines, and package boundaries using internal/.
Next, you trace how goroutines, channels, select, mutexes, and context.Context deadlines fit together, and verify shared state under go test -race so goroutine leaks and data races fail in tests instead of production. The final sections cover structured logging with log/slog, middleware chains, HTTP server timeouts, database/sql connection pooling and transactions, and graceful shutdown on OS signals.
Course access
-
Interfaces and Standard Abstractions (empty)3Lessons · 15 min
-
Interfaces Are Satisfied Implicitly
Define small one-method interfaces, satisfy them without implements keywords, and swap real dependencies for bytes.Buffer in tests. After this, you can decouple callers from concrete types.
5 min -
Read and Stream With io.Reader and io.Writer
Process files and network streams in bounded memory using bufio.Scanner, io.Copy, and io.LimitReader. After this, you can handle large payloads without loading them all into RAM.
5 min -
-
-
Context, Timeouts, and Cancellation (empty)3Lessons · 15 min
-
Use context.Context for Deadlines and Cancellation
Pass context.Context as the first parameter, create deadlines with context.WithTimeout, and always defer cancel(). After this, slow or abandoned work stops instead of hanging.
5 min -
Set Timeouts on HTTP Clients and Server Handlers
Replace http.Get with http.NewRequestWithContext and configure explicit client and server timeouts. After this, external API calls and incoming requests respect strict time budgets.
5 min -
-
-
Goroutines, Channels, and Coordination (empty)3Lessons · 15 min
-
Run Concurrent Work Safely With sync.WaitGroup
Launch concurrent tasks with sync.WaitGroup, collect results without shared-memory races, and verify safety with go test -race. After this, you can parallelize I/O without data races.
5 min -
Coordinate Pipelines and Timeouts With Channels and select
Send values safely over channels, close channels from the sender, and multiplex with select and ctx.Done(). After this, goroutines exit cleanly instead of leaking.
5 min -
-
-
Structured Logging and Databases (empty)3Lessons · 15 min
-
Write Structured JSON Logs With log/slog
Emit machine-readable JSON logs with log/slog, attach typed key-value fields, and derive request-scoped loggers. After this, your service logs are easy to filter and alert on.
5 min -
Query Relational Data Safely With database/sql
Run parameterized queries with QueryRowContext and QueryContext, handle sql.ErrNoRows, and always close rows. After this, you can integrate SQL databases without leaks or injection bugs.
5 min -
-
-
Middleware and Production-Ready Services (empty)3Lessons · 15 min
-
Wrap HTTP Handlers With Middleware
Build composable func(http.Handler) http.Handler middleware and wrap http.ResponseWriter to record response status codes. After this, cross-cutting logging and headers stay out of handlers.
5 min -
Build a Multi-Route Service With Graceful Shutdown
Wire signal.NotifyContext and server.Shutdown(ctx) so in-flight HTTP requests finish before exit, and verify with go test -race. After this, deploys drop zero active requests.
5 min -
-
-
Generics, Transactions, Timers, and Test Doubles (empty)5Lessons · 25 min
-
Generics, Constraints, and slices/maps Packages
Write type-safe generic helpers with comparable and cmp.Ordered, and reuse standard slices and maps utilities. After this, you avoid boilerplate without overusing any.
5 min -
SQL Transactions and Connection Pool Limits
Run atomic multi-statement SQL writes with db.BeginTx and defer tx.Rollback(), and bound connections with SetMaxOpenConns. After this, partial writes and exhausted DB pools stop happening.
5 min -
Timers, Tickers, and Avoiding time.After Leaks
Replace time.After inside loops with reusable time.NewTimer and stopped time.NewTicker instances. After this, long-running workers stay flat on memory.
5 min -
Testing With Interface Fakes, t.TempDir, and testdata
Keep unit tests fast and isolated using consumer-side interfaces, auto-cleaned t.TempDir() directories, and testdata/ fixtures. After this, file and dependency tests run reliably in parallel.
5 min -
-
About
This course is for developers who can already write standalone Go programs and now need services that compose cleanly, handle concurrency safely, and behave predictably when dependencies stall. You start with consumer-side interfaces, typed-nil pitfalls, streaming io.Reader and io.Writer pipelines, and package boundaries using internal/.
Next, you trace how goroutines, channels, select, mutexes, and context.Context deadlines fit together, and verify shared state under go test -race so goroutine leaks and data races fail in tests instead of production. The final sections cover structured logging with log/slog, middleware chains, HTTP server timeouts, database/sql connection pooling and transactions, and graceful shutdown on OS signals.
- Responsible
- Jay P
- Last Update
- 11/27/2026
- Completion Time
- 1 h 40 min
- Members
- 1
Reviews
Sign in to write a reviewComments
Sign in to commentNo comments yet.