1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

doc: update doc for system package

This commit is contained in:
dudaodong
2022-12-30 14:28:49 +08:00
parent e996d4c945
commit 54834dba4c
3 changed files with 55 additions and 21 deletions

View File

@@ -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)
- **<big>IsWindows</big>** : 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)]
- **<big>IsLinux</big>** : 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)]
- **<big>IsMac</big>** : 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)]
- **<big>GetOsEnv</big>** : 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-)]
- **<big>SetOsEnv</big>** : 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-)]
- **<big>RemoveOsEnv</big>** : 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)]
- **<big>CompareOsEnv</big>** : 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)]
- **<big>ExecCommand</big>** : 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)]
- **<big>GetOsBits</big>** : 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.

View File

@@ -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)
- **<big>IsWindows</big>** : 检查当前操作系统是否是windows。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#IsWindows)]
[[play](https://go.dev/play/p/XzJULbzmf9m)]
- **<big>IsLinux</big>** : 检查当前操作系统是否是linux。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#IsLinux)]
[[play](https://go.dev/play/p/zIflQgZNuxD)]
- **<big>IsMac</big>** : 检查当前操作系统是否是macos。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#IsMac)]
[[play](https://go.dev/play/p/Mg4Hjtyq7Zc)]
- **<big>GetOsEnv</big>** : 根据key获取对应的环境变量值
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#GetOsEnv)]
[[play](https://go.dev/play/p/D88OYVCyjO-)]
- **<big>SetOsEnv</big>** : 设置环境变量。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#SetOsEnv)]
[[play](https://go.dev/play/p/D88OYVCyjO-)]
- **<big>RemoveOsEnv</big>** : 删除环境变量。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#RemoveOsEnv)]
[[play](https://go.dev/play/p/fqyq4b3xUFQ)]
- **<big>CompareOsEnv</big>** : 换取环境变量并与传入值进行比较。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#CompareOsEnv)]
[[play](https://go.dev/play/p/BciHrKYOHbp)]
- **<big>ExecCommand</big>** : 执行shell命令。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#ExecCommand)]
[[play](https://go.dev/play/p/n-2fLyZef-4)]
- **<big>GetOsBits</big>** : 获取当前操作系统位数(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验证器包包含常用字符串格式验证函数。

View File

@@ -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)