问题描述
我写了一个golang程序并调用了ethereum包,以便使用ethereum函数。调用以太坊函数的代码如下(当然我的程序中还有其他代码): 包主
import (
"fmt"
"github.com/ethereum/go-ethereum/p2p"
)
func (cli *CLI) getPeerInfo() {
var server = new(p2p.Server)
server.Start()
a:=server.NodeInfo()
//return a
fmt.Printf(a.Enode)
}
可以看到我只是想使用以太坊函数获取节点信息,但是编译运行后,显示如下错误:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x4f429e]
goroutine 1 [running]:
github.com/ethereum/go-ethereum/p2p.(*Server).Self(0xc00019ca00,0x0)
C:/tools/src/github.com/ethereum/go-ethereum/p2p/server.go:386 +0xfe
github.com/ethereum/go-ethereum/p2p.(*Server).NodeInfo(0xc00019ca00,0x0)
C:/tools/src/github.com/ethereum/go-ethereum/p2p/server.go:1077 +0x5e
main.(*CLI).getPeerInfo(0xc00007df78)
C:/tools/src/github.com/liangjian/blockchain_go/cli_getpeerinfo.go:10 +0x59
main.(*CLI).Run(0xc00007df78)
C:/tools/src/github.com/liangjian/blockchain_go/cli.go:165 +0xbdd
main.main()
C:/tools/src/github.com/liangjian/blockchain_go/main.go:5 +0x32
Debugger finished with exit code 0
如何解决?非常感谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)