doubi1818 2015-06-06 19:18
浏览 206
已采纳

go程序抛出错误,找不到软件包“ code.google.com/p/go.net/websocket”

I am new to Go programming language. Below is my code.

package main

import (
    "code.google.com/p/go.net/websocket"
    "fmt"
    "net/http"
    "strconv"
)

var add := "12345"

func EchoLengthServer(ws *webscoket.Conn) {
    var msg string

    for {
        websocket.Message.Receive(ws, &msg)
        fmt.Println("Got Message", msg)
        length := len(msg)
        if err := websocket.Message.Send(ws, strconv.FormatInt(int64(length), 10)); err != nil {
            fmt.Println("can't send message length")
            break
        }
    }
}

func websocketListen() {
    http.Handle("/length", websocket.Handler(EchoLengthServer))
    err := http.ListenAndServe(addr, nil)
    if err != nil {
        panic("ListenAndServe:" + err.Error())
    }
}

when I executed the code i got below error

[rajkumar@localhost ch4-DesigningAPI]$ go run WebSockets.go 
WebSockets.go:6:3: cannot find package "code.google.com/p/go.net/websocket" in any of:
    /usr/local/go/src/code.google.com/p/go.net/websocket (from $GOROOT)
    /home/rajkumar/GOPackages/src/code.google.com/p/go.net/websocket (from $GOPATH)

I tried to add websocket package in GOPATH by go get command but that is also throwing below error

[rajkumar@localhost ch4-DesigningAPI]$ go get code.google.com/p/go.net/websocket
go: missing Mercurial command. See http://golang.org/s/gogetcmd
package code.google.com/p/go.net/websocket: exec: "hg": executable file not found in $PATH

Could you please help me in resolving this error.

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 关于bitwise and/or 的问题
      • ¥30 nodejs child_process通信问题
      • ¥15 pretous做定时闹钟,keil的C语言程序下载到pretous仿真图中可以运行,但是运行结果不太对,麻烦哪位大神帮忙调一下。
      • ¥15 C语言高精度加减法出了问题
      • ¥15 用matlab来完成这两个程序
      • ¥15 如何在pyecharts绘制的图像上添加窗口?
      • ¥15 8086CPU汇编语言
      • ¥35 哪位大佬可以帮忙做一下,有赏金
      • ¥15 51单片机c语言制作数字电子时钟
      • ¥15 求大神帮忙看看这一题