英文:
Go - JSON-RPC - "too many colons"
问题
我正在尝试使用Go(不在GAE上)调用比特币的HTTP JSON-RPC服务器,但是我遇到了以下错误:
dial tcp http://user:pass@127.0.0.1:8332: 地址中有太多冒号
或者
dial ip http://user:pass@127.0.0.1:8332: 查找 http://user:pass@127.0.0.1:8332: 没有这样的主机
我尝试了各种网络配置,但是没有任何进展。当我只是在浏览器中输入地址时,我从服务器得到了响应:
{"result":null,"error":{"code":-32700,"message":"解析错误"},"id":null}
这看起来像是一个空调用的正确响应。
我该如何正确地在Go中调用该HTTP JSON-RPC服务器?
英文:
I'm trying to call a HTTP JSON-RPC server for Bitcoin using Go (not on GAE), but I get error of
dial tcp http://user:pass@127.0.0.1:8332: too many colons in address
or
dial ip http://user:pass@127.0.0.1:8332: lookup http://user:pass@127.0.0.1:8332: no such host
I tried various network configurations, but couldn't get anything going. When I just typed the address into the browser, I got a response from the server:
{"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}
Which looks like a proper response for an empty call.
How do I correctly call that HTTP JSON-RPC server in Go?
答案1
得分: 11
参考:
http://golang.org/src/pkg/net/ipsock.go?s=2247:2304#L68
英文:
Use brackets around the host like this:
[user:pass@127.0.0.1]:8332
Reference:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论