From a8c4e2a4c40b2f552e68ee20042b2a9e7f5c10ea Mon Sep 17 00:00:00 2001 From: qydysky Date: Sun, 26 Jul 2020 11:05:09 +0800 Subject: [PATCH] 4 --- Sys.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Sys.go 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 -- 2.39.2