This is a creation in Article, where the information may have evolved or changed.
Package Mainimport ("Code.google.com/p/go.net/websocket" "FMT" "Log" "Net/http" "Html/template") func Echo (WS * WebSocket. Conn) {var err errorfor{fmt. Println ("Start") var reply stringif err = WebSocket. Message.receive (WS, &reply); Err! = nil{fmt. Println ("Can ' t receive") Break}fmt. Println ("Received back from client:" + Reply) Msg: = "Received:" + replyfmt. PRINTLN ("Sending to Cient:" + msg) If Err = WebSocket. Message.send (WS, MSG); Err! = nil{fmt. Println ("Can ' t send") break}}}func Chat (w http. Responsewriter, R *http. Request) {r.parseform () fmt. Println (r.form) t,_: = template. Parsefiles ("websocket_demo.html") T.execute (W, nil)}func main () {http. Handle ("/", WebSocket. Handler (Echo)) http. Handlefunc ("/chat", chat) If err: = http. Listenandserve (": 9999", nil); Err! = Nil{log. Fatal ("Listentandserve:", err)}}=============================================================================== ===========