2017-10-07 17 views
-1

我想从源(我想用调试器跟踪执行)运行以太坊,我在编译时遇到问题。这是我得到的错误:不能使用函数作为输入的类型

[[email protected] sources]$ go run github.com/ethereum/go-ethereum/cmd/geth/main.go github.com/ethereum/go-ethereum/cmd/geth/config.go github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go github.com/ethereum/go-ethereum/cmd/geth/monitorcmd.go github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go gopkg.in/urfave/cli.v1 --verbosity 5 --ipcdisable --port 40401 --rpc --rpcport 9101 --pprof --datadir=/home/niko/saved-niko-home/myeth/ --networkid=15 console 
# command-line-arguments 
github.com/ethereum/go-ethereum/cmd/geth/config.go:42: cannot use dumpConfig (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go:43: cannot use initGenesis (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go:60: cannot use importChain (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go:78: cannot use exportChain (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go:95: cannot use removeDB (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/chaincmd.go:108: cannot use dump (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/monitorcmd.go:52: cannot use monitor (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go:50: cannot use importWallet (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go:96: cannot use accountList (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go:107: cannot use accountCreate (type func(*"gopkg.in/urfave/cli.v1".Context) error) as type func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) error in argument to utils.MigrateFlags 
github.com/ethereum/go-ethereum/cmd/geth/accountcmd.go:107: too many errors 
[[email protected]st sources]$ 
[[email protected] sources]$ echo $GOPATH 
/home/niko/sources/github.com/ethereum/go-ethereum/build/_workspace/:/home/niko/sources/github.com/ethereum/go-ethereum/vendor:/home/niko/go 
[[email protected] sources]$ 

,你可以看到它抱怨说:

func(*"gopkg.in/urfave/cli.v1".Context) 

是不一样的:

func(*"github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1".Context) 

然而,这是一样的,因为我手动将其复制到/ home/niko/go,其中包含我所有的Go包:

[[email protected] sources]$ find /home/niko/go -iname "*cli.v1*" 
/home/niko/go/src/gopkg.in/urfave/cli.v1 
/home/niko/go/pkg/linux_amd64/gopkg.in/urfave/cli.v1.a 
[[email protected] sources]$ 

而且这是我GOPATH

那么,我该如何解决这个错误得到,我怎么告诉转到该软件包是一个好?

+2

虽然不一样 - 路径不同。这使得它们不同 – Flimzy

+0

@Flimzy代码所在的路径属于Go的可重用软件包应该在的标准位置,即在GOPATH目录中 – Nulik

+0

这并不重要。该代码预计它是自动售货机。所以,如果它不在自动售货目录中,那就错了。 – Flimzy

回答

1

github.com/ethereum/go-ethereum/vendor/gopkg.in/urfave/cli.v1

gopkg.in/urfave/cli.v1

是不同的导入路径封装,无论是内容,他们被认为是不同的。

这里的问题是,你的程序以某种方式从不同的位置加载两次,导致你提供的错误消息。

我不是你使用的go run命令行那么清楚,我宁愿做,

go run github.com/ethereum/go-ethereum/cmd/geth/*go --verbosity 5 --ipcdisable --port 40401 --rpc --rpcport 9101 --pprof --datadir=/home/niko/saved-niko-home/myeth/ --networkid=15 console 

除非你想破解复仇,我看不出有任何理由它的依赖复制到您的GOPATH。 因为他们出售他们的依赖关系(IE:他们复制他们的依赖关系到供应商文件夹)ref:https://github.com/ethereum/go-ethereum/tree/master/vendor你真的应该使用这些。

关于您GOPATH

/home/niko/sources/github.com/ethereum/go-ethereum/build/_workspace/:/home/niko/sources/github.com/ethereum/go-ethereum/vendor:/home/niko/go

它不会对我来说很好。

如果GOPATH=/home/niko/sources/,然后,

tree $GOPATH -L 1 
/home/niko/sources/ 
├── bin 
├── pkg 
└── src 

3 directories, 0 files 

而且ls -al $GOPATH/src/github.com/ethereum/go-ethereum应该是正确的。

另请参阅go env

+0

是的,你是完全正确的,函数被定义了两次,因为我在命令行手动提供源文件。但是,如果我忽略它们,我会得到另一个问题,这是张贴在这里:https://stackoverflow.com/questions/46626072/problems-building-go-code-from-sources – Nulik

+1

在src,pkg目录有效。谢谢! – Nulik

相关问题