英文:
Run Golang script from shell script
问题
我正在尝试在每次登录到OSX时运行我的golang程序。我正在尝试使用Automator和以下脚本:
#!/bin/sh
export GOPATH=/Volumes/DTSE9/worker
go run /Volumes/worker/worker.go
每当我使用Automator运行这个脚本时,它告诉我go: command not found
。
英文:
I'm trying to run my golang program whenever I log into OSX. I'm trying the following script with Automator:
#!/bin/sh
export GOPATH=/Volumes/DTSE9/worker
go run /Volumes/worker/worker.go
Whenever I run this with Automator, it tells me go: command not found
答案1
得分: 2
创建一个名为file.go
的文件,其内容应如下所示:
///path-to/bin/go run $0 $@; exit $?
package main
func main() {
println("Hello World!")
}
然后运行chmod +x file.go
,然后你可以使用./file.go p1 p2
来执行它。
编辑:这在Ubuntu上有效。我没有看到有关OSX的问题。
英文:
Create a file like say file.go
and it's content should look like:
///path-to/bin/go run $0 $@; exit $?
package main
func main() {
println("Hello World!")
}
Then run chmod +x file.go
and then you can execute it as ./file.go p1 p2
.
Edit: This works on Ubuntu. I did not saw that OSX was in question.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论