Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct { }
Builder 运行 go build 的时候,用于获取当前的路径 go build 只会编译当前的工程生成一个可执行的二进制文件
type Executor ¶
type Executor struct { }
Executor 实际编译为二进制可执行文件之后,还是得靠 Builder(os.Executable()) 获取到 二进制文件的实际目录,这样才能真正做到相对路径的配置文件读取
type Runner ¶
type Runner struct { }
Runner 运行 go run 的时候,用于获取运行时的路径 go run 如果是直接用工程的方式运行,它会直接编译当前的源码到一个临时的文件目录 这个临时文件目录取决于系统对于 TEMP or TMP 环境变量的设置 MacOS: env | grep TMP --> TMPDIR=/var/folders/xr/wk8s14091t18004kjvgkc9kh0000gp/T/ 那么之后若使用 filepath.Abs(filepath.Dir(os.Args[0])) 得到的输出如下: /private/var/folders/xr/wk8s14091t18004kjvgkc9kh0000gp/T/GoLand
Click to show internal directories.
Click to hide internal directories.