问题
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:
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.
来源:https://stackoverflow.com/questions/42865472/run-golang-script-from-shell-script