github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2012/chat/support/websocket.go (about) 1 // +build OMIT 2 3 package main 4 5 import ( 6 "fmt" 7 "golang.org/x/net/websocket" 8 "net/http" 9 ) 10 11 func main() { 12 http.Handle("/", websocket.Handler(handler)) 13 http.ListenAndServe("localhost:4000", nil) 14 } 15 16 func handler(c *websocket.Conn) { 17 var s string 18 fmt.Fscan(c, &s) 19 fmt.Println("Received:", s) 20 fmt.Fprint(c, "How do you do?") 21 }