docs: fix the graceful shutdown example (#4809)

The example calls errors.Is but never imports errors, so copying it as
written fails to build with "undefined: errors".

It also passes an unbuffered channel to signal.Notify, which go vet
reports as a misuse: signal delivery is non-blocking, so a signal that
arrives before the receive is dropped.
This commit is contained in:
Wahid Rizka Fathurrohman 2026-09-19 13:21:21 +07:00 committed by GitHub
parent b1f77cf536
commit 8ad9f9cbea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2399,6 +2399,7 @@ package main
import (
"context"
"errors"
"log"
"net/http"
"os"
@ -2431,7 +2432,7 @@ func main() {
// Wait for interrupt signal to gracefully shutdown the server with
// a timeout of 5 seconds.
quit := make(chan os.Signal)
quit := make(chan os.Signal, 1)
// kill (no param) default send syscall.SIGTERM
// kill -2 is syscall.SIGINT
// kill -9 is syscall.SIGKILL but can't be caught, so don't need to add it