aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-08-15 18:57:20 -0400
committerDeterminant <ted.sybil@gmail.com>2019-08-15 18:57:20 -0400
commit1c1fa76addab68e04e051df3f38cce9f3bb32d98 (patch)
tree4fd8ae6f9973642f0ac58ee5b9af81669ac4cddb
parentff58d84f81d584646ca3f8fe00493cdcec8239ed (diff)
auto detect gopath
-rw-r--r--examples/counter/main.go7
1 files changed, 6 insertions, 1 deletions
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)