osKit

package
v2.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PathSeparator 路径分隔符(string类型)
	/*
		e.g. Mac
		"/"
	*/
	PathSeparator = string(os.PathSeparator)

	// PathListSeparator 路径列表分隔符(string类型)
	/*
		e.g. Mac
		":"
	*/
	PathListSeparator = string(os.PathListSeparator)
)

Variables

View Source
var ARCH string

ARCH 处理器架构

View Source
var BITS int

BITS 操作系统的位数(32 || 64)

参考: Go获取操作系统位数 https://blog.csdn.net/TCatTime/article/details/106815724

OS 操作系统

Functions

func ExitWithCode

func ExitWithCode(code int)

ExitWithCode 退出程序

PS: 无论是在main程还是子程中,只要调用os.Exit(),程序就会终止.

@param code 0:正常退出;非0:非正常退出(一般用1)

func GetEnv

func GetEnv(key string, defArgs ...string) string

GetEnv (带默认值地)获取系统环境变量.

@param key 可以为"" @return 可能为""

e.g. ("") => "" ("JAVA_HOME") => "/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home"

func GetMaxOpenFiles

func GetMaxOpenFiles() (int, error)

GetMaxOpenFiles 同一时间最多可开启的文件数

PS: (1) 当前仅支持Mac、Linux环境. (2) 为何使用 sh -c "ulimit -n" 而非 ulimit -n? https://www.thinbug.com/q/17483723

func GetUserMaxProcesses

func GetUserMaxProcesses() (int, error)

GetUserMaxProcesses 用户最多可开启的程序数目

PS: (1) 仅支持Mac、Linux环境; (2) Process: 进程.

func IsLinux

func IsLinux() bool

func IsMac

func IsMac() bool

func IsWindows

func IsWindows() bool

func SetEnvs

func SetEnvs(m map[string]string) error

SetEnvs 一次性设置多个系统变量.

@param m 可以为nil @return 如果发生error的话,返回第一个

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL