utils

package
v0.0.0-...-5f127d6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2022 License: CC-BY-SA-4.0 Imports: 6 Imported by: 0

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 只会编译当前的工程生成一个可执行的二进制文件

func (*Builder) Path

func (b *Builder) Path() (abs string, err error)

type Executor

type Executor struct {
}

Executor 实际编译为二进制可执行文件之后,还是得靠 Builder(os.Executable()) 获取到 二进制文件的实际目录,这样才能真正做到相对路径的配置文件读取

func (*Executor) Path

func (e *Executor) Path() (abs string, err error)

type Pather

type Pather interface {
	Path() (path string, err error)
}

type Rooter

type Rooter struct {
}

func (*Rooter) Path

func (r *Rooter) Path() (root string, err error)

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

func (*Runner) Path

func (r *Runner) Path() (abs string, err error)

Jump to

Keyboard shortcuts

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