mirror of
https://github.com/gin-gonic/gin.git
synced 2026-11-27 14:13:40 +08:00
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:
parent
b1f77cf536
commit
8ad9f9cbea
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user