From 54834dba4ce38337413aad98c05018a063931f75 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Fri, 30 Dec 2022 14:28:49 +0800 Subject: [PATCH] doc: update doc for system package --- README.md | 37 +++++++++++++++++++++++++++---------- README_zh-CN.md | 37 +++++++++++++++++++++++++++---------- system/os.go | 2 +- 3 files changed, 55 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index e5504d4..6bd47c1 100644 --- a/README.md +++ b/README.md @@ -566,16 +566,33 @@ import "github.com/duke-git/lancet/v2/system" ``` #### Function list: - -- [IsWindows](https://github.com/duke-git/lancet/blob/main/docs/system.md#IsWindows) -- [IsLinux](https://github.com/duke-git/lancet/blob/main/docs/system.md#IsLinux) -- [IsMac](https://github.com/duke-git/lancet/blob/main/docs/system.md#IsMac) -- [GetOsEnv](https://github.com/duke-git/lancet/blob/main/docs/system.md#GetOsEnv) -- [SetOsEnv](https://github.com/duke-git/lancet/blob/main/docs/system.md#SetOsEnv) -- [RemoveOsEnv](https://github.com/duke-git/lancet/blob/main/docs/system.md#RemoveOsEnv) -- [CompareOsEnv](https://github.com/duke-git/lancet/blob/main/docs/system.md#CompareOsEnv) -- [ExecCommand](https://github.com/duke-git/lancet/blob/main/docs/system.md#ExecCommand) -- [GetOsBits](https://github.com/duke-git/lancet/blob/main/docs/system.md#GetOsBits) +- **IsWindows** : check if current os is windows. +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#IsWindows)] +[[play](https://go.dev/play/p/XzJULbzmf9m)] +- **IsLinux** : check if current os is linux. +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#IsLinux)] +[[play](https://go.dev/play/p/zIflQgZNuxD)] +- **IsMac** : check if current os is macos. +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#IsMac)] +[[play](https://go.dev/play/p/Mg4Hjtyq7Zc)] +- **GetOsEnv** : get the value of the environment variable named by the key. +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#GetOsEnv)] +[[play](https://go.dev/play/p/D88OYVCyjO-)] +- **SetOsEnv** : set the value of the environment variable named by the key. +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#SetOsEnv)] +[[play](https://go.dev/play/p/D88OYVCyjO-)] +- **RemoveOsEnv** : remove a single environment variable. +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#RemoveOsEnv)] +[[play](https://go.dev/play/p/fqyq4b3xUFQ)] +- **CompareOsEnv** : get env named by the key and compare it with passed env. +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#CompareOsEnv)] +[[play](https://go.dev/play/p/BciHrKYOHbp)] +- **ExecCommand** : execute command, return the stdout and stderr string of command, and error if error occurs. +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#ExecCommand)] +[[play](https://go.dev/play/p/n-2fLyZef-4)] +- **GetOsBits** : return current os bits (32 or 64). +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#GetOsBits)] +[[play](https://go.dev/play/p/ml-_XH3gJbW)] ### 19. Validator package contains some functions for data validation. diff --git a/README_zh-CN.md b/README_zh-CN.md index a868b0f..66ccc74 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -562,16 +562,33 @@ import "github.com/duke-git/lancet/v2/system" ``` #### 函数列表: - -- [IsWindows](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN.md#IsWindows) -- [IsLinux](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN.md#IsLinux) -- [IsMac](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN.md#IsMac) -- [GetOsEnv](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN.md#GetOsEnv) -- [SetOsEnv](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN.md#SetOsEnv) -- [RemoveOsEnv](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN.md#RemoveOsEnv) -- [CompareOsEnv](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN.md#CompareOsEnv) -- [ExecCommand](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN.md#ExecCommand) -- [GetOsBits](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN.md#GetOsBits) +- **IsWindows** : 检查当前操作系统是否是windows。 +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#IsWindows)] +[[play](https://go.dev/play/p/XzJULbzmf9m)] +- **IsLinux** : 检查当前操作系统是否是linux。 +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#IsLinux)] +[[play](https://go.dev/play/p/zIflQgZNuxD)] +- **IsMac** : 检查当前操作系统是否是macos。 +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#IsMac)] +[[play](https://go.dev/play/p/Mg4Hjtyq7Zc)] +- **GetOsEnv** : 根据key获取对应的环境变量值 +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#GetOsEnv)] +[[play](https://go.dev/play/p/D88OYVCyjO-)] +- **SetOsEnv** : 设置环境变量。 +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#SetOsEnv)] +[[play](https://go.dev/play/p/D88OYVCyjO-)] +- **RemoveOsEnv** : 删除环境变量。 +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#RemoveOsEnv)] +[[play](https://go.dev/play/p/fqyq4b3xUFQ)] +- **CompareOsEnv** : 换取环境变量并与传入值进行比较。 +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#CompareOsEnv)] +[[play](https://go.dev/play/p/BciHrKYOHbp)] +- **ExecCommand** : 执行shell命令。 +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#ExecCommand)] +[[play](https://go.dev/play/p/n-2fLyZef-4)] +- **GetOsBits** : 获取当前操作系统位数(32/64)。 +[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#GetOsBits)] +[[play](https://go.dev/play/p/ml-_XH3gJbW)] ### 19. validator验证器包,包含常用字符串格式验证函数。 diff --git a/system/os.go b/system/os.go index 3a85bf1..55ac2e9 100644 --- a/system/os.go +++ b/system/os.go @@ -117,7 +117,7 @@ func byteToString(data []byte, charset string) string { return result } -// GetOsBits return this system bits (32 or 64) +// GetOsBits return current os bits (32 or 64). // Play: https://go.dev/play/p/ml-_XH3gJbW func GetOsBits() int { return 32 << (^uint(0) >> 63)