将 go websocket 库更新到最新版本
我正在 Ubuntu 上运行 Go 编译器,使用 sudo apt-get install golang
安装
我已经成功编译并执行了一个简单示例服务器的代码(请参阅 http://golang.org/pkg/websocket/#Handler )
package main
import (
"http"
"io"
"websocket"
)
// Echo the data received on the Web Socket.
func EchoServer(ws *websocket.Conn) {
io.Copy(ws, ws);
}
func main() {
http.Handle("/echo", websocket.Handler(EchoServer));
err := http.ListenAndServe(":12345", nil);
if err != nil {
panic("ListenAndServe: " + err.String())
}
}
但是,我无法连接到服务器与我的版本铬 (16.0.912.77)。我假设 Chrome 已经实现了 RFC 6455 Websocket(版本 13),但是 Ubuntu golang 包中的 go websocket 库已经过时了。
所以,我的问题是:如何仅将 websocket 包更新到最新版本?
I am running the Go compiler on Ubuntu, installed using sudo apt-get install golang
I've successfully compiled and executed the code for a Trivial example server (See http://golang.org/pkg/websocket/#Handler )
package main
import (
"http"
"io"
"websocket"
)
// Echo the data received on the Web Socket.
func EchoServer(ws *websocket.Conn) {
io.Copy(ws, ws);
}
func main() {
http.Handle("/echo", websocket.Handler(EchoServer));
err := http.ListenAndServe(":12345", nil);
if err != nil {
panic("ListenAndServe: " + err.String())
}
}
However, I fail to connect to the server with my version of Chromium (16.0.912.77). I assume Chrome has implemented the RFC 6455 Websocket (version 13), but that the go websocket library in the Ubuntu golang package is out of date.
So, my question is: How can I update only the websocket package to the latest version?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Go
websocket
软件包的最新版本是net/websocket
,位于code.google.com/p/go.net/websocket
,它需要Go 1 每周开发版本。对于 Ubuntu golang-weekly:适用于 Go 的 Ubuntu PPA 软件包。
每周开发发布文档:Go 编程语言。
The latest version of the Go
websocket
package isnet/websocket
atcode.google.com/p/go.net/websocket
, which requires the Go 1 weekly development release.For Ubuntu golang-weekly: Ubuntu PPA packages for Go.
For weekly development release documentation: Go Programming Language.
我猜Ubuntu软件包存储库中的Go版本可能是r60.3(左右),现在有点旧了。使用最新的每周,将代码更改为:
此外,在websocket包中
s/ParseRequestURI/ParseRequest/
,那么它在这里似乎可以工作。(1)更新< /strong>:抱歉,我写/读太快了,似乎不起作用,页面显示:“不是 websocket 协议”(这里是 64b Ubuntu 上的 Chrome 18.0.1025.33 beta 10.04)
更新 2012-08-22:上面 (1) 有关编辑 websocket 包的说明不再有效。 websocket 包同时已更新,上面的示例(主要)代码现在可以编译,不会出现问题。不管怎样,我还没有测试过它之后是否做了应该做的事情,抱歉。
I guess the version of Go in Ubuntu package repository is probably r60.3 (or so), which is a bit old now. Use latest weekly, change the code to:
Moreover in the websocket package
s/ParseRequestURI/ParseRequest/
, then it seems to work here.(1)Update: Sorry, I wrote/read too fast, it doesn't seem to work, the page shows: "not websocket protocol" (here is Chrome 18.0.1025.33 beta on 64b Ubuntu 10.04)
Update 2012-08-22: The above (1) note about editing the websocket package doesn't hold anymore. The websocket package has been meanwhile updated and the example (main) code above now compiles w/o problems. Anyway, I haven't tested if it afterwards does what is should or not, sorry.