From 1c1fa76addab68e04e051df3f38cce9f3bb32d98 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 15 Aug 2019 18:57:20 -0400 Subject: auto detect gopath --- examples/counter/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/counter/main.go b/examples/counter/main.go index 662fea1..e7961e5 100644 --- a/examples/counter/main.go +++ b/examples/counter/main.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "go/build" "math/big" "os" "os/signal" @@ -65,7 +66,11 @@ func main() { config.Miner.ManualUncle = true // compile the smart contract - counterSrc, err := filepath.Abs("./counter.sol") + gopath := os.Getenv("GOPATH") + if gopath == "" { + gopath = build.Default.GOPATH + } + counterSrc, err := filepath.Abs(gopath + "/src/github.com/ava-labs/coreth/examples/counter/counter.sol") checkError(err) contracts, err := compiler.CompileSolidity("", counterSrc) checkError(err) -- cgit v1.2.3-70-g09d2