From 71b7bb5cb6939d9900bab7fd17ddc822ba51899d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Sat, 18 Jun 2022 08:00:46 +0800 Subject: [PATCH] - update service - update tool --- service/help.md | 1 + tool/help.md | 1 + tool/system/os.go | 18 ++++++++++++++++++ tool/system/os_test.go | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 service/help.md create mode 100644 tool/help.md create mode 100644 tool/system/os.go create mode 100644 tool/system/os_test.go diff --git a/service/help.md b/service/help.md new file mode 100644 index 00000000..a5d44c1a --- /dev/null +++ b/service/help.md @@ -0,0 +1 @@ +### 服务 \ No newline at end of file diff --git a/tool/help.md b/tool/help.md new file mode 100644 index 00000000..800a6a35 --- /dev/null +++ b/tool/help.md @@ -0,0 +1 @@ +### 工具 \ No newline at end of file diff --git a/tool/system/os.go b/tool/system/os.go new file mode 100644 index 00000000..5af0d39e --- /dev/null +++ b/tool/system/os.go @@ -0,0 +1,18 @@ +package system + +import "runtime" + +// IsMac 是否为Mac +func IsMac() bool { + return runtime.GOOS == "darwin" +} + +// IsWindows 是否为Windows +func IsWindows() bool { + return runtime.GOOS == "windows" +} + +// IsLinux 是否为Linux +func IsLinux() bool { + return runtime.GOOS == "linux" +} diff --git a/tool/system/os_test.go b/tool/system/os_test.go new file mode 100644 index 00000000..592657c0 --- /dev/null +++ b/tool/system/os_test.go @@ -0,0 +1,33 @@ +package system + +import "testing" + +func TestIsMac(t *testing.T) { + t.Log(IsMac()) +} + +func BenchmarkIsMac(b *testing.B) { + for i := 0; i < b.N; i++ { + IsMac() + } +} + +func TestIsWindows(t *testing.T) { + t.Log(IsWindows()) +} + +func BenchmarkIsWindows(b *testing.B) { + for i := 0; i < b.N; i++ { + IsWindows() + } +} + +func TestIsLinux(t *testing.T) { + t.Log(IsWindows()) +} + +func BenchmarkIsLinux(b *testing.B) { + for i := 0; i < b.N; i++ { + IsWindows() + } +}