gosh能使运行.go文件如同运行脚本文件一样。
可以在要运行的.go文件开头加入shebang行,如:
#!/path/to/gosh
这样的话,以下两种方式都可以运行:
./gosh ./hello.go
chmod +x hello.go
./hello.go
如果不加入,那么只能使用这种方法运行:
./gosh ./hello.go
传递参数只需在后面附上即可。重定向输入输出也如普通的程序一样。
要编译的.go文件、编译后的二进制文件均会放在/tmp下,具体路径即为/tmp/+原路径。
程序通过比较.go文件的修改时间来判断是否需要重新编译。