currently I'm trying to debug golang implementation of ethereum(link), because my core interest is in developing new consensus algorithm (i.e. modify the open source Golang code from github).
However, I'm having problem with the location/path of the source code. When I put the folder(i.e. go-ethereum
) outside of the $GOPATH
and then try to compile&debug geth
(go-ethereum/cmd/geth/main.go
) it shows the following error: Use of internal package is not allowed.
From that error message, I figured out that the import github.com/ethereum/go-ethereum
was not importing my source, and instead it was getting code from internet(like other libraries). Which of course is definitely what I shouldn't do when I'm trying to modify the github.com/ethereum/go-ethereum
package code.
So, my workaround was to clone the source code into $GOPATH/src/github.com/ethereum/go-ethereum
and followed this answer, and Goland IDE started compiling&debugging without error (wasn't able to go build ./cmd/geth/main.go
though due to error undefined: configFileFlag...
)
Thereby now I've got a working debugger that can debug with my source code modification, but this doesn't look like ideal source code structure.
The question is:
Is putting source code inside $GOPATH
(because of internals) a proper approach? If so, what if I was using go-ethereum
package from another project?(Fortunately I'm not, but I'm curious) Do I have to stash&revert changes I made to the code?