From: qydysky Date: Sun, 26 Jul 2020 03:05:09 +0000 (+0800) Subject: 4 X-Git-Tag: v0.0.2~88 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=a8c4e2a4c40b2f552e68ee20042b2a9e7f5c10ea;p=part%2F.git 4 --- diff --git a/Sys.go b/Sys.go new file mode 100644 index 0000000..b95060c --- /dev/null +++ b/Sys.go @@ -0,0 +1,44 @@ +package part + +import ( + "sync" + "path/filepath" + "os" + "runtime" + "time" + "strconv" +) + +type sys struct {sync.Mutex} + +func Sys () *sys { + return &sys{} +} + +func (this *sys) Cdir()string{ + this.Lock() + defer this.Unlock() + + dir, _ := os.Executable() + exPath := filepath.Dir(dir) + return exPath +} + +func (this *sys) Timeoutf(Timeout int) { + this.Lock() + defer this.Unlock() + + time.Sleep(time.Duration(Timeout)*time.Second) +} + +func (this *sys) GetSys(sys string)bool{ + this.Lock() + defer this.Unlock() + + return runtime.GOOS==sys +} + +func (this *sys) GetTime() string { + now := strconv.FormatInt(time.Now().Unix(),10) + return now[len(now)-4:] +} \ No newline at end of file