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() + } +}