Documentation ¶
Index ¶
- func CompareOsEnv(key, comparedEnv string) bool
- func ExecCommand(command string, opts ...Option) (stdout, stderr string, exitCode int, err error)
- func GetAllIP() (map[string][]string, error)
- func GetAllIPV4Slice() ([]string, error)
- func GetExecDir() (string, error)
- func GetHomeDir() string
- func GetHostInfo() (host.InfoStat, error)
- func GetOsBits() int
- func GetOsEnv(key string) string
- func GetOutboundIP() (string, error)
- func GetOutboundIPByInterfaceAndRoute() (string, error)
- func IsLinux() bool
- func IsMac() bool
- func IsWindows() bool
- func RandomPort(blackList []uint16) uint16
- func RandomSubnetIP() string
- func RandomSubnetIPWithBlackList(blackList []string) string
- func RemoveOsEnv(key string) error
- func SetOsEnv(key, value string) error
- func VerifyPortIsUnused(port uint16) (bool, error)
- func VerifyRuntimeEnv() (string, error)
- type CurrentUserInfo
- type NetInterfaceInfo
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareOsEnv ¶ added in v0.0.17
CompareOsEnv gets env named by the key and compare it with comparedEnv. Play: https://go.dev/play/p/BciHrKYOHbp
func ExecCommand ¶ added in v0.0.17
ExecCommand execute command, return the stdout and stderr string and exitCode of command, and error if error occur param `command` is a complete command string, like, ls -a (linux), dir(windows), ping 127.0.0.1 in linux, use /bin/bash -c to execute command in windows, use powershell.exe to execute command Play: https://go.dev/play/p/n-2fLyZef-4
func GetHomeDir ¶ added in v0.0.5
func GetHomeDir() string
func GetOsBits ¶ added in v0.0.17
func GetOsBits() int
GetOsBits return current os bits (32 or 64). Play: https://go.dev/play/p/ml-_XH3gJbW
func GetOsEnv ¶ added in v0.0.17
GetOsEnv gets the value of the environment variable named by the key. Play: https://go.dev/play/p/D88OYVCyjO-
func GetOutboundIPByInterfaceAndRoute ¶ added in v0.0.18
获取本机首选IP地址的另一种备选方案
func IsLinux ¶ added in v0.0.17
func IsLinux() bool
IsLinux check if current os is linux. Play: https://go.dev/play/p/zIflQgZNuxD
func IsMac ¶ added in v0.0.17
func IsMac() bool
IsMac check if current os is macos. Play: https://go.dev/play/p/Mg4Hjtyq7Zc
func IsWindows ¶ added in v0.0.17
func IsWindows() bool
IsWindows check if current os is windows. Play: https://go.dev/play/p/XzJULbzmf9m
func RandomSubnetIPWithBlackList ¶
带黑名单的生成随机IP网段
func RemoveOsEnv ¶ added in v0.0.17
RemoveOsEnv remove a single environment variable. Play: https://go.dev/play/p/fqyq4b3xUFQ
func SetOsEnv ¶ added in v0.0.17
SetOsEnv sets the value of the environment variable named by the key. Play: https://go.dev/play/p/D88OYVCyjO-
func VerifyRuntimeEnv ¶
检查运行环境类型, Linux主机、K8S的Pod、Docker容器 - host: Linux主机 - pod: K8S的Pod - container: Docker容器 - unknown: 其他未知的情况
Types ¶
type CurrentUserInfo ¶ added in v0.0.2
func GetCurrentUserInfo ¶ added in v0.0.2
func GetCurrentUserInfo() (CurrentUserInfo, error)
获取当前用户信息
type NetInterfaceInfo ¶ added in v0.0.18
type NetInterfaceInfo struct { Index int // positive integer that starts at one, zero is never used MTU int // maximum transmission unit Name string // e.g., "en0", "lo0", "eth0.100" HardwareAddr string // IEEE MAC-48, EUI-48 and EUI-64 form Flags string // e.g., FlagUp, FlagLoopback, FlagMulticast IPV4Addr string IPV6Addr string }
func GetNetInterfacesInfo ¶ added in v0.0.18
func GetNetInterfacesInfo() ([]NetInterfaceInfo, error)
获取本机所有网卡对应的IP地址信息
type Option ¶ added in v0.0.17
func WithForeground ¶ added in v0.0.17
func WithForeground() Option
func WithWinHide ¶ added in v0.0.17
func WithWinHide() Option