I want to run simple go code directly from the terminal / command line. For instance:
go run "
package main
func main() {
println("hello")
}
"
hello
However, golang only allows code from a file to be executed. So maybe there are some ways to imitate him? Like this:
go run file.go < echo "...."
But there should be no files after the steps above.
source
share