系统变量初始化
Context
ctx, _ := context.WithTimeout(context.Background(), 15 * time.Second)
获取当前路径
package main
import (
"os"
"path/filepath"
)
func main() {
// 据说这个方法在某些特别场景会获取到错误的路径
dir1, _ := os.Getwd()
//推荐使用下面的方法
dir2, _ := os.Executable()
exPath := filepath.Dir(dir2)
println(exPath2)
}