Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(428)

Delta Between Two Patch Sets: src/pkg/os/signal/example_test.go

Issue 6615078: code review 6615078: os/signal: add Notify example (Closed)
Left Patch Set: Created 11 years, 5 months ago
Right Patch Set: diff -r 57e13fc87f43 https://code.google.com/p/go Created 11 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package signal_test 1 package signal_test
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "os" 5 "os"
6 "os/signal" 6 "os/signal"
7 ) 7 )
8 8
9 func ExampleNotify() { 9 func ExampleNotify() {
10 » c := make(chan os.Signal) 10 » // Set up channel on which to send signal notifications.
11 » // We must use a buffered channel or risk missing the signal
12 » // if we're not ready to receive when the signal is sent.
13 » c := make(chan os.Signal, 1)
11 signal.Notify(c, os.Interrupt, os.Kill) 14 signal.Notify(c, os.Interrupt, os.Kill)
12 » fmt.Println("Waiting for signal...") 15
16 » // Block until a signal is received.
13 s := <-c 17 s := <-c
14 fmt.Println("Got signal:", s) 18 fmt.Println("Got signal:", s)
15 } 19 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b