15 lines
418 B
Bash
Executable File
15 lines
418 B
Bash
Executable File
#!/bin/sh
|
|
|
|
script_path=$(realpath $0)
|
|
script_dir=$(dirname $script_path)
|
|
|
|
cd $script_dir
|
|
|
|
output=/tmp/commandgo
|
|
|
|
# 为什么不直接使用 go run . 呢
|
|
# 因为 go run 编译时会往 PATH 里注入 Go 的 bin 目录,这个修改过后的 PATH 会传递给子进程
|
|
# 于是程序运行起来时获取的 PATH 环境变量和外界不一致,因此不用 go run . 编译运行
|
|
go build -o $output . && $output $@
|
|
|