Go - JSON-RPC - “太多冒号”

时间:2012-01-13 17:27:05

标签: http communication go json-rpc

我正在尝试使用Go(而不是GAE)调用HTTP JSON-RPC server for Bitcoin,但是我收到错误

dial tcp http://user:pass@127.0.0.1:8332: too many colons in address

dial ip http://user:pass@127.0.0.1:8332: lookup http://user:pass@127.0.0.1:8332: no such host

我尝试了各种network configurations,但无法进行任何操作。当我在浏览器中输入地址时,我收到了服务器的响应:

{"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}

对于空呼叫,这看起来像是一个正确的响应。

如何在Go中正确调用HTTP JSON-RPC服务器?

1 个答案:

答案 0 :(得分:9)

在主机周围使用括号,如下所示:

[user:pass@127.0.0.1]:8332

参考:

http://golang.org/src/pkg/net/ipsock.go?s=2247:2304#L68