I am trying to write a script in Go but I get this error:
bad interpreter: Permission denied
My super simple script is as follow:
#!/usr/local/Cellar/go/1.0.2/bin
fmt.Println("Hello World")
I don´t know if this is possible but I would really like to write scripts in Go since I like the language a lot.
Go isn't a scripting language. Like in C you have to compile your source code to make an executable.
From the "Getting Started" :
Create a file named hello.go and put the following program in it:
package main
import "fmt"
func main() {
fmt.Printf("hello, world
")
}
Then run it with the go tool:
$ go run hello.go
hello, world
In the spirit of Python, there are attempts to make Go scripts kinda possible. Here's for example what you can do with gorun :
#!/usr/bin/gorun
package main
func main() {
println("Hello world!")
}
But that's not really the logic of Go and that's not nearly as simple as what you typed in your question.