@@ -25,6 +25,12 @@ and it is used for the development of backend services.
2525> [ !NOTE]
2626> C background is ** required** for learning Go.
2727
28+ > [ !IMPORTANT]
29+ > The examples in this repository target ** Go 1.26** and make use of features
30+ > introduced in that release. See the
31+ > [ Go 1.26 features used in this repo] ( #go-126-features-used-in-this-repo )
32+ > section below for the highlights.
33+
2834## Outline (As a separate course)
2935
3036- History
@@ -39,16 +45,19 @@ and it is used for the development of backend services.
3945- ` struct `
4046- ` interface `
4147- Pointers
42- - Errors
43- - Concurrency and channels
48+ - Errors (including the generic ` errors.AsType[E] ` from Go 1.26)
49+ - Concurrency and channels ( ` sync.WaitGroup.Go ` , ` sync.OnceValue ` )
4450- ` select `
51+ - Generics (including self-referential type parameters from Go 1.26)
4552- ` go mod ` and using packages
4653- An overview of advanced features
4754- Introduction to HTTP protocol
48- - HTTP server implementation
49- - Settings management paragraph
55+ - HTTP server implementation with ` net/http ` 's pattern-based routing
56+ and structured logging via ` log/slog ` (` slog.NewMultiHandler ` )
57+ - Graceful shutdown with ` signal.NotifyContext ` cancel causes
58+ - Settings management
5059- Metric, Log and Tracing
51- - connection with the database using PostgreSQL and GORM
60+ - Connection with the database using PostgreSQL and GORM
5261- Introduction to Docker and containerization
5362
5463At the beginning of the course, an introduction to the Go language is made and students implement simple programs with it.
@@ -92,24 +101,59 @@ Reviewing these source codes are useful for learning Go but there aren't enough.
9210122 . JSON
9310223 . ` go.mod `
9410324 . Packages
95- 25 . Self-referential generics (Go 1.26)
104+ 25 . ` defer `
105+ 26 . ` variadic `
106+ 27 . ` regex `
107+ 28 . ` sync.Once ` / ` sync.OnceValue `
108+ 29 . ` panic `
109+ 30 . UTF-8
110+ 31 . The ` nil ` interface trap
111+ 32 . Type aliases vs. type definitions
112+ 33 . Self-referential generics (Go 1.26)
96113
97114### Go 1.26 features used in this repo
98115
99- - ` new(expr) ` for inline pointer initialization — see ` 22-json/ `
100- - ` errors.AsType[E] ` generic error assertion — see ` 16-errors/ `
101- - ` slog.NewMultiHandler ` log fan-out — see ` httpserver/main.go `
102- - ` signal.NotifyContext ` cancel-cause shutdown — see ` httpserver/main.go `
103- - Self-referential generic type parameters — see ` 33-generics-self-referential/ `
104- - ` go fix -modernize ` — run with ` just modernize `
105-
106- ### Echo
107-
108- 0 . Say hello to Echo
109- 1 . HTTP Handlers
110- 2 . Request Binding
111- 3 . Path Parameters
112- 4 . Query Strings
116+ This repository has been refreshed to use ** Go 1.26** language and library
117+ features. The most notable ones — and where to find a runnable example for
118+ each — are:
119+
120+ | Feature | Where |
121+ | -------------------------------------------------------------- | -------------------------------------------------------------------------------- |
122+ | ` new(expr) ` builtin: pointer + initial value in one step | [ ` 22-json/main.go ` ] ( ./22-json/main.go ) |
123+ | ` errors.AsType[E] ` — generic, type-safe ` errors.As ` | [ ` 16-errors/main.go ` ] ( ./16-errors/main.go ) |
124+ | Self-referential generic type parameters (` Adder[A Adder[A]] ` ) | [ ` 33-generics-self-referential/main.go ` ] ( ./33-generics-self-referential/main.go ) |
125+ | ` slog.NewMultiHandler ` for log fan-out | [ ` httpserver/main.go ` ] ( ./httpserver/main.go ) |
126+ | ` signal.NotifyContext ` + ` context.Cause ` for graceful shutdown | [ ` httpserver/main.go ` ] ( ./httpserver/main.go ) |
127+
128+ The repository also benefits from earlier-but-still-modern features that are
129+ worth highlighting in class:
130+
131+ - ` sync.WaitGroup.Go(func) ` instead of ` Add ` / ` go ` / ` defer Done `
132+ (see [ ` 17-concurrency/main.go ` ] ( ./17-concurrency/main.go ) and
133+ [ ` 20-pipeline/main.go ` ] ( ./20-pipeline/main.go ) )
134+ - ` sync.OnceValue ` instead of ` sync.Once ` + sentinel field
135+ (see [ ` 28-once/main.go ` ] ( ./28-once/main.go ) )
136+ - ` for range N ` instead of the C-style ` for i := 0; i < N; i++ `
137+ (see [ ` 09-map ` ] ( ./09-map/main.go ) , [ ` 19-channels-1 ` ] ( ./19-channels-1/main.go ) ,
138+ [ ` 20-pipeline ` ] ( ./20-pipeline/main.go ) , [ ` 23-sharding ` ] ( ./23-sharding/main.go ) )
139+ - ` math/rand/v2 ` (see [ ` 21-select/main.go ` ] ( ./21-select/main.go ) )
140+ - ` net/http ` pattern-based routing — ` mux.HandleFunc("GET /hello/{username}", …) `
141+ (see [ ` httpserver/main.go ` ] ( ./httpserver/main.go ) )
142+ - ` mime.ParseMediaType ` for tolerant ` Content-Type ` checks
143+ (see [ ` httpserver/handler/hello.go ` ] ( ./httpserver/handler/hello.go ) )
144+
145+ ### Keeping the codebase modern
146+
147+ Go 1.26 ships a much expanded ` go fix ` with a suite of _ modernizer_ analyzers
148+ that automatically rewrite older idioms (` interface{} ` → ` any ` ,
149+ ` for i := 0; i < n; i++ ` → ` for range n ` , ` WaitGroup.Add ` /` Done ` → ` WaitGroup.Go ` ,
150+ and many more). To run all of them across this module:
151+
152+ ``` sh
153+ just modernize
154+ # or, equivalently:
155+ go fix ./...
156+ ```
113157
114158## Continue your journey 🧳
115159
0 commit comments