@@ -18,19 +18,24 @@ func main() {
|
||||
|
||||
// Go signal notification works by sending `os.Signal`
|
||||
// values on a channel. We'll create a channel to
|
||||
// receive these notifications (we'll also make one to
|
||||
// notify us when the program can exit).
|
||||
// receive these notifications. Note that this channel
|
||||
// should be buffered.
|
||||
sigs := make(chan os.Signal, 1)
|
||||
done := make(chan bool, 1)
|
||||
|
||||
// `signal.Notify` registers the given channel to
|
||||
// receive notifications of the specified signals.
|
||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
// This goroutine executes a blocking receive for
|
||||
// signals. When it gets one it'll print it out
|
||||
// and then notify the program that it can finish.
|
||||
// We could receive from `sigs` here in the main
|
||||
// function, but let's see how this could also be
|
||||
// done in a separate goroutine, to demonstrate
|
||||
// a more realistic scenario of graceful shutdown.
|
||||
done := make(chan bool, 1)
|
||||
|
||||
go func() {
|
||||
// This goroutine executes a blocking receive for
|
||||
// signals. When it gets one it'll print it out
|
||||
// and then notify the program that it can finish.
|
||||
sig := <-sigs
|
||||
fmt.Println()
|
||||
fmt.Println(sig)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
ccee3fe41771b7cf56d64de38b12588022458154
|
||||
YRV64KEXJW1
|
||||
cd15508731199185f3205692af0f80cbdee4fcd7
|
||||
LauPuRo3v9l
|
||||
|
||||
@@ -66,3 +66,9 @@ func TestIntMinTableDriven(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIntMin(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
IntMin(1, 2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
c9ca6b71d9f762b689f1f08a490d8c7f7764fcb3
|
||||
vY8PN0c6BSx
|
||||
25e8941d63b555a590e6d44a95ae0e41ecadadca
|
||||
ALL2BVLkYEr
|
||||
|
||||
Reference in New Issue
Block a user