Created
April 11, 2012 01:43
-
-
Save jordanorelli/2356279 to your computer and use it in GitHub Desktop.
whyyyyyyy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
) | |
func main() { | |
count := 0 | |
quit := make(chan os.Signal) | |
signal.Notify(quit, syscall.SIGINT) | |
for { | |
select { | |
case <-quit: | |
goto STANLEY | |
default: | |
count += 1 | |
fmt.Println(count) | |
} | |
} | |
STANLEY: | |
fmt.Println("done") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
) | |
func main() { | |
count := 0 | |
quit := make(chan os.Signal) | |
signal.Notify(quit, syscall.SIGINT) | |
for { | |
select { | |
case <-quit: | |
break | |
default: | |
count += 1 | |
fmt.Println(count) | |
} | |
} | |
fmt.Println("done") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
) | |
func count(quit chan bool) { | |
var count int | |
for { | |
select { | |
case <-quit: | |
break | |
default: | |
count += 1 | |
fmt.Println(count) | |
} | |
} | |
} | |
func main() { | |
quit := make(chan bool) | |
sig := make(chan os.Signal) | |
signal.Notify(sig, syscall.SIGINT) | |
go count(quit) | |
<-sig | |
quit <- true | |
fmt.Println("done") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment