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

huangapple go评论102阅读模式
英文:

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:

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

huangapple
  • 本文由 发表于 2012年1月14日 01:27:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/8854682.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定