
Alex Edwards
Привет, я Алекс Эдвардс, full-stack веб-разработчик. Я начал работать с Golang 6 лет назад в 2013 году и почти столько же времени обучаю людей и пишу о языке. Я использовал Go для создания разнообразных производственных приложений, от простых веб-сайтов до высокочастотных торговых систем. Я также работаю над несколькими пакетами Go с открытым исходным кодом, включая популярную систему управления сессиями SCS.
Go 1.22 http.ServeMux updates
The standard library http.ServeMux is now used for routing throughout the book instead of julienschmidt/httprouter.
There are two new chapters --- 2.4. (Wildcard route patterns) and 2.5. (Method-based routing) --- which explain how to use the new http.ServeMux routing features. Chapter 2.3. (Routing requests) has also been rewritten to reflect the Go 1.22 changes. The old Section 7. (Advanced routing) has been removed entirely.
The change to use the new http.ServeMux routing features had a few additional knock-on effects.
Because http.ServeMux doesn't make it possible to easily serve custom 404 responses without breaking 405 responses (see https://github.com/golang/go/issues/61410#issuecomment-1871202015), the book no longer uses a custom notFound() helper. Instead, the http.NotFound() function is used whenever we need to send a 404 response.
How to work with query strings is now covered at the end of Chapter 7.2. (Parsing form data).
The information on customizing HTTP status codes and response headers has been rewritten, and can now be found in Chapter 2.6. (Customizing responses).
Other Go 1.22 language updates
Chapter 9.5. (Configuring HTTPS settings) has been updated to reflect that http.Server now only supports TLS 1.2 and TLS 1.3 by default.
Chapter 12.1. (Embedding static files) has been updated to use the new http.FileServerFS() function for serving static files.
Chapter 13.8. (Profiling test coverage) has been updated to reflect the new output generated by go test -cover.
Other updates
Chapter 4.3. (Modules and reproducible builds) has been updated to explain the // indirect annotation in go.mod files.
The openDB() function in Chapter 4.4. (Creating a database connection pool) has been updated to close the connection pool before returning in the event of a failed Ping().
The secureHeaders() middleware in chapter 6.2. has been renamed to commonHeaders().
Chapter 9.3. (Generating a self-signed TLS certificate) now suggests using the mkcert tool as an alternative to generating your own self-signed certificates.
The newTestDB() function in Chapter 13.7. (Integration testing) has been updated to always close the connection pool before returning in the event of an error.
Dependency updates
github.com/alexedwards/scs/mysqlstore -> v0.0.0-20240203174419-a38e822451b6
github.com/alexedwards/scs/v2 -> v2.8.0
github.com/go-sql-driver/mysql -> v1.8.0
golang.org/x/crypto -> v0.21.0
Miscellaneous
Various typo fixes and minor copy tweaks to improve clarity. Thanks to everyone who provided feedback!
The current update is for: Go 1.18
The current update is for: Go 1.18
The current update is for: Go 1.18