I'm able to run a Go application as a website with Apache using the following code.
hello.go:
package main
import (
"os"
)
func main() {
os.Stdout.WriteString("Content-Type: text/html; charset=UTF-8
")
os.Stdout.WriteString("Hello!
")
}
.htaccess:
AddHandler cgi-script .exe
I compile the app using go build hello.go
and going to http://localhost/hello.exe
works as expected.
But now I have to recompile after every change I make in the sourcecode.
Is it somehow possible to tell Apache to run hello.go
(Apache should run go run hello.go
) when visiting http://localhost/hello.go
?
By the way, this is only to speed development, not for production!