diff --git a/cef/homedir.go b/cef/homedir.go index a6c57f991ef4ea58ffa33af59a35e29c477b7620..f239cf9df61c79b95e3cd1b6566c831d6e8a3228 100644 --- a/cef/homedir.go +++ b/cef/homedir.go @@ -11,10 +11,10 @@ package cef import ( "bytes" "errors" + "github.com/energye/energy/common" "os" "os/exec" "path/filepath" - "runtime" "strconv" "strings" "sync" @@ -46,7 +46,7 @@ func Dir() (string, error) { var result string var err error - if runtime.GOOS == "windows" { + if common.IsWindows() { result, err = dirWindows() } else { // Unix-like system, so just assume Unix @@ -96,7 +96,7 @@ func Reset() { func dirUnix() (string, error) { homeEnv := "HOME" - if runtime.GOOS == "plan9" { + if common.IsPlan9() { // On plan9, env vars are lowercase. homeEnv = "home" } @@ -109,7 +109,7 @@ func dirUnix() (string, error) { var stdout bytes.Buffer // If that fails, try OS specific commands - if runtime.GOOS == "darwin" { + if common.IsDarwin() { cmd := exec.Command("sh", "-c", `dscl -q . -read /Users/"$(whoami)" NFSHomeDirectory | sed 's/^[^ ]*: //'`) cmd.Stdout = &stdout if err := cmd.Run(); err == nil { diff --git a/common/assetserve/server_test.go b/common/assetserve/server_test.go index 5728413a4f32562cdb74fd4874387f99c1d138f3..a531e1480d3da3f1025c038eb8e5d70f76cc7569 100644 --- a/common/assetserve/server_test.go +++ b/common/assetserve/server_test.go @@ -2,7 +2,6 @@ package assetserve import ( "embed" - "fmt" "testing" ) @@ -13,6 +12,5 @@ func TestServer(t *testing.T) { server := NewAssetsHttpServer() server.AssetsFSName = "assets" //必须设置目录名 server.Assets = &assets - err := server.StartHttpServer() - fmt.Println(err) + server.StartHttpServer() //go server.StartHttpServer() } diff --git a/common/common.go b/common/common.go index f02fb88bb82f0c3bbd70135c0c8e1955bdfa6cde..9393cca1c42cd1142550e8ad87c5f79ee22543f7 100644 --- a/common/common.go +++ b/common/common.go @@ -27,13 +27,26 @@ import ( ) const ( - IntSize = strconv.IntSize - IntSize32 = 32 - intSize64 = 64 - - isWindows = runtime.GOOS == "windows" - isLinux = runtime.GOOS == "linux" - isDarwin = runtime.GOOS == "darwin" + IntSize = strconv.IntSize //bit + IntSize32 = 32 // + intSize64 = 64 // + isWindows = runtime.GOOS == "windows" //support + isLinux = runtime.GOOS == "linux" //support + isDarwin = runtime.GOOS == "darwin" //support + isAndroid = runtime.GOOS == "android" //not support + isIos = runtime.GOOS == "ios" //not support + isPlan9 = runtime.GOOS == "plan9" //not support + isAix = runtime.GOOS == "aix" //not support + isDragonfly = runtime.GOOS == "dragonfly" //not support + isFreebsd = runtime.GOOS == "freebsd" //not support + isHurd = runtime.GOOS == "hurd" //not support + isIllumos = runtime.GOOS == "illumos" //not support + isJs = runtime.GOOS == "js" //not support + isNacl = runtime.GOOS == "nacl" //not support + isNetbsd = runtime.GOOS == "netbsd" //not support + isOpenbsd = runtime.GOOS == "openbsd" //not support + isSolaris = runtime.GOOS == "solaris" //not support + isZos = runtime.GOOS == "zos" //not support ) func Proc(index int) dllimports.ProcAddr { @@ -52,6 +65,10 @@ func IsDarwin() bool { return isDarwin } +func IsPlan9() bool { + return isPlan9 +} + func StrToInt64(value string) int64 { v, _ := strconv.ParseInt(value, 10, 64) return v