2017-10-07 18 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

相關問題