Documentation
¶
Index ¶
- func ExeDir() string
- func ExeExt() string
- func ExeFull() string
- func ExeName() string
- func GetEnv[T cast.Basic](value T, names ...string) T
- func GetModuleVersion(name string) string
- func Hostname() string
- func IsDebug() bool
- func Panic(v any)
- func Panicf(format string, args ...any)
- func WithExeExt(ext string) string
- func WorkDir() string
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEnv ¶
GetEnv 按 names 的先后顺序读取并转换第一个已设置的环境变量。 环境变量即使为空或转换失败也会立即返回转换结果,不再尝试后续名称; 所有环境变量都未设置时返回 value。
func GetModuleVersion ¶ added in v1.5.5
GetModuleVersion 返回指定模块在当前程序构建信息中的版本。 模块使用 replace 时返回替换模块的版本;无法取得版本时返回 v0.0.0。
func IsDebug ¶
func IsDebug() bool
IsDebug 判断程序是否处于调试模式。 命令行包含以 "-test." 开头的参数,或 DEBUG 环境变量为 1、t、true、y、yes、on 中的任意值时返回 true。
func WithExeExt ¶
WithExeExt 返回将可执行文件扩展名替换为 ext 后的完整路径。 ext 缺少前导点时自动补齐;ext 为空时返回不含扩展名的路径。
Types ¶
Click to show internal directories.
Click to hide internal directories.