Help us shape the future of Go! Take the 2026 Go Developer Survey

platform

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppDir

func AppDir() (string, error)

AppDir 返回当前可执行文件所在的目录。

func BundledModelsDir

func BundledModelsDir(appDir string) string

BundledModelsDir 返回打包自带的模型目录路径(绝对路径)。

func DataDir

func DataDir() string

DataDir 返回应用数据目录(绝对路径)。

Windows: exe 目录可写时返回 exe 目录(portable 模式,旧用户零迁移); 不可写(如装到 Program Files)时 fallback 到 %LOCALAPPDATA%\Goink。 其他平台: 返回 ~/Goink/。 开发模式下 exe 位于临时目录时,所有平台统一返回 ~/Goink/。 环境变量 GOINK_DATA_DIR 可覆盖以上逻辑,用于集成测试。

结果用 sync.Once 缓存,避免每次调用都做可写性检测。

func ResetDataDirCache added in v1.4.3

func ResetDataDirCache()

ResetDataDirCache 重置 DataDir 的 sync.Once 缓存,供测试使用。 测试用例用 t.Setenv("GOINK_DATA_DIR", ...) 设置不同的临时目录后, 需要调用此函数重置缓存,否则 DataDir() 仍返回第一次调用的缓存值。 生产代码不应调用此函数。

func ResolveGit

func ResolveGit() (string, error)

ResolveGit 返回 git 可执行文件的路径。 搜索顺序: app 自带 runtime/git/ → 用户数据目录 runtime/git/ → 系统 PATH。 每个候选路径都会验证可执行性(git --version),不可用则跳过继续 fallback。

当环境变量 GOINK_TESTING=1 时,仅从 DataDir 的 bundled 路径查找, 不 fallback 到系统 PATH,找不到直接报错。用于 E2E 测试确保使用 bundled git。

func ResolveOnnxLib

func ResolveOnnxLib() (string, error)

ResolveOnnxLib 返回 ONNX Runtime 动态库的路径。 优先 app 自带的 runtime/,然后用户数据目录 runtime/,最后系统路径。

当环境变量 GOINK_TESTING=1 时,仅从 DataDir 的 runtime/ 查找, 不 fallback 到系统路径,找不到直接报错。用于 E2E 测试确保使用 bundled ONNX。

func SetPlatformAttr

func SetPlatformAttr(*exec.Cmd)

SetPlatformAttr 为子进程设置平台相关属性(非 Windows 平台为空操作)。

Types

This section is empty.

Jump to

Keyboard shortcuts

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