Update README.md

Fix incorrect graceful shutdown examples.
This commit is contained in:
Yixin Xu 2021-02-14 20:51:23 +08:00 committed by GitHub
parent 1bdf86b722
commit 7cdedf8e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1793,8 +1793,8 @@ func main() {
// Initializing the server in a goroutine so that // Initializing the server in a goroutine so that
// it won't block the graceful shutdown handling below // it won't block the graceful shutdown handling below
go func() { go func() {
if err := srv.ListenAndServe(); err != nil && errors.Is(err, http.ErrServerClosed) { if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Printf("listen: %s\n", err) log.Fatalf("Failed to listen and serve: %s\n", err)
} }
}() }()