]> 127.0.0.1 Git - part/.git/commitdiff
4
authorqydysky <qydysky@foxmail.com>
Sun, 26 Jul 2020 03:05:09 +0000 (11:05 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 26 Jul 2020 03:05:09 +0000 (11:05 +0800)
Sys.go [new file with mode: 0644]

diff --git a/Sys.go b/Sys.go
new file mode 100644 (file)
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