Skip to content

Commit 2eac87b

Browse files
authored
Merge pull request #1 from hycka/f-dev
f-dev
2 parents f8cb162 + 7332e5e commit 2eac87b

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

opencc.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"os"
1010
"path/filepath"
1111
"reflect"
12-
"runtime"
1312
"strings"
1413

14+
"github.com/hi20160616/gears"
1515
"github.com/liuzl/da"
1616
)
1717

@@ -23,14 +23,22 @@ var (
2323
)
2424

2525
func defaultDir() string {
26-
if runtime.GOOS == "windows" {
27-
return `C:\gocc\`
28-
}
2926
if goPath, ok := os.LookupEnv("GOPATH"); ok {
30-
return goPath + "/src/github.com/liuzl/gocc/"
31-
} else {
32-
return `/usr/local/share/gocc/`
27+
//judge whether the path exists
28+
//goPath + "/src/github.com/liuzl/gocc/" or "/pkg/mod/github.com/liuzl/gocc/"
29+
//if those path do not exist, return current work dir
30+
p := goPath + "/src/github.com/liuzl/gocc/"
31+
if gears.Exists(p) {
32+
return p
33+
} else if p = goPath + "/pkg/mod/github.com/liuzl/gocc?/"; gears.Exists(p) {
34+
return p
35+
}
36+
}
37+
path, err := os.Getwd()
38+
if err != nil {
39+
return ""
3340
}
41+
return path + "/internal/gocc/"
3442
}
3543

3644
// Group holds a sequence of dicts

0 commit comments

Comments
 (0)