osx

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExeDir

func ExeDir() string

ExeDir 返回可执行文件所在目录。

func ExeExt

func ExeExt() string

ExeExt 返回包含前导点的可执行文件扩展名;没有扩展名时返回空字符串。

func ExeFull

func ExeFull() string

ExeFull 返回包初始化时读取并缓存的可执行文件完整路径。

func ExeName

func ExeName() string

ExeName 返回不包含目录和扩展名的可执行文件名称。

func GetEnv

func GetEnv[T cast.Basic](value T, names ...string) T

GetEnv 按 names 的先后顺序读取并转换第一个已设置的环境变量。 环境变量即使为空或转换失败也会立即返回转换结果,不再尝试后续名称; 所有环境变量都未设置时返回 value。

func GetModuleVersion added in v1.5.5

func GetModuleVersion(name string) string

GetModuleVersion 返回指定模块在当前程序构建信息中的版本。 模块使用 replace 时返回替换模块的版本;无法取得版本时返回 v0.0.0。

func Hostname

func Hostname() string

Hostname 返回当前主机名;读取失败时返回空字符串。

func IsDebug

func IsDebug() bool

IsDebug 判断程序是否处于调试模式。 命令行包含以 "-test." 开头的参数,或 DEBUG 环境变量为 1、t、true、y、yes、on 中的任意值时返回 true。

func Panic

func Panic(v any)

Panic 先将给定值和从调用方开始的调用堆栈以易读格式打印到标准错误输出,再调用 panic 保持原有行为。

func Panicf

func Panicf(format string, args ...any)

Panicf 按 format 格式化参数后,行为与 Panic 一致。

func WithExeExt

func WithExeExt(ext string) string

WithExeExt 返回将可执行文件扩展名替换为 ext 后的完整路径。 ext 缺少前导点时自动补齐;ext 为空时返回不含扩展名的路径。

func WorkDir

func WorkDir() string

WorkDir 返回当前工作目录;读取失败时返回空字符串。

Types

type Version

type Version struct {
	Type     string
	Version  string
	Revision string
	Time     string
	Dirty    bool

	GoVersion string
	Compiler  string
	Platform  string
}

Version 描述当前程序的版本、版本控制和 Go 构建信息。

func GetVersion

func GetVersion() Version

GetVersion 返回程序构建信息,结果只计算一次并缓存。

func (Version) String

func (v Version) String() string

String 以缩进后的 JSON 格式返回版本信息。

Jump to

Keyboard shortcuts

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