Finish the mirror feature. Finish the prototype of zip compress.

This commit is contained in:
zicla
2019-04-28 22:18:42 +08:00
parent a4f28cca30
commit 6e0078e1d8
25 changed files with 800 additions and 128 deletions

View File

@ -0,0 +1,46 @@
package util
import (
"os"
"os/user"
"strings"
)
//是否为win开发环境
func EnvWinDevelopment() bool {
ex, err := os.Executable()
if err != nil {
panic(err)
}
//如果exPath中包含了 \\AppData\\Local\\Temp 我们认为是在Win的开发环境中
systemUser, err := user.Current()
if systemUser != nil {
return strings.HasPrefix(ex, systemUser.HomeDir+"\\AppData\\Local\\Temp")
}
return false
}
//是否为mac开发环境
func EnvMacDevelopment() bool {
ex, err := os.Executable()
if err != nil {
panic(err)
}
return strings.HasPrefix(ex, "/private/var/folders")
}
//是否为开发环境 (即是否在IDE中运行)
func EnvDevelopment() bool {
return EnvWinDevelopment() || EnvMacDevelopment()
}