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

Side by Side Diff: 2014/go4java/battle.go

Issue 111050043: code review 111050043: go.talks: add "Go for Javaneros" (Closed)
Patch Set: diff -r f10c43fe60f9 https://code.google.com/p/go.talks Created 9 years, 8 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:
View unified diff | Download patch
OLDNEW
(Empty)
1 package main
2
3 import (
4 "fmt"
5 "net/http"
6 )
7
8 var battle = make(chan string)
9
10 func handler(w http.ResponseWriter, q *http.Request) {
11 select {
12 case battle <- q.FormValue("usr"):
13 fmt.Fprintf(w, "You won!")
14 case won := <-battle:
15 fmt.Fprintf(w, "You lost, %v is better than you", won)
16 }
17 }
18
19 func main() {
20 http.HandleFunc("/fight", handler)
21 http.ListenAndServe("localhost:8080", nil)
22 }
OLDNEW

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