您如何确定go中当前正在运行的可执行文件的完整路径?

您如何确定go中当前正在运行的可执行文件的完整路径?,第1张

您如何确定go中当前正在运行的可执行文件的完整路径

我认为这是传统的 *** 作方式,我认为它可以在任何平台上使用。

import (    "fmt"    "os"    "path/filepath")// Shortcut to get the path to the current executablefunc ExecPath() string {    var here = os.Args[0]    here, err := filepath.Abs(here)    if err != nil {        fmt.Printf("Weird path: %sn", err)    }    return here}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5126193.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存