Go - JSON-RPC - “too many colons”

时光总嘲笑我的痴心妄想 提交于 2019-12-30 12:04:11

问题


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:


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



来源:https://stackoverflow.com/questions/8854682/go-json-rpc-too-many-colons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!