Skip to content

Commit 85e0447

Browse files
committed
Fixed asset path error. Fixes bnb-chain#29
1 parent fbd53f0 commit 85e0447

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

‎ui/ui_lib.go‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/ethereum/eth-go"
66
"github.com/ethereum/eth-go/ethutil"
77
"github.com/niemeyer/qml"
8+
"os"
89
"path"
910
"path/filepath"
1011
"runtime"
@@ -49,18 +50,26 @@ func (ui *UiLib) AssetPath(p string) string {
4950

5051
func AssetPath(p string) string {
5152
var base string
52-
switch runtime.GOOS {
53-
case "darwin":
54-
// Get Binary Directory
55-
exedir, _ := osext.ExecutableFolder()
56-
base = filepath.Join(exedir, "../Resources")
57-
base = "/Users/jeffrey/go/src/github.com/ethereum/go-ethereum"
58-
case "linux":
59-
base = "/usr/share/ethereal"
60-
case "window":
61-
fallthrough
62-
default:
63-
base = "."
53+
54+
// If the current working directory is the go-ethereum dir
55+
// assume a debug build and use the source directory as
56+
// asset directory.
57+
pwd, _ := os.Getwd()
58+
if pwd == path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum") {
59+
base = pwd
60+
} else {
61+
switch runtime.GOOS {
62+
case "darwin":
63+
// Get Binary Directory
64+
exedir, _ := osext.ExecutableFolder()
65+
base = filepath.Join(exedir, "../Resources")
66+
case "linux":
67+
base = "/usr/share/ethereal"
68+
case "window":
69+
fallthrough
70+
default:
71+
base = "."
72+
}
6473
}
6574

6675
return path.Join(base, p)

0 commit comments

Comments
 (0)