Google Go (golang) as CGI
The following steps should get you serving content rendered by Google Go through Apache and cgi. This is probably painfully obvious to anyone who has done cgi before, but as I have always worked with higher level stuff, this actually took a little figurin' out.
(I'll take a stab at fcgi next...)
1) Create plain.go
package main
import (
"os"
)
func main() {
os.Stdout.WriteString("Content-Type: text/plain;charset=us-ascii\n\n");
os.Stdout.WriteString("Hello world!\n\n");
}
2) Compile and link it
8g plain.go
8l -o plain.cgi plain.8
3) Setup your .htaccess file
Options +FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
That should be all there is to it. You can test the .cgi file by simply running it from the command line as well. Other information that might be useful is that the query string will be in an environment variable called "QUERY_STRING", and POST data will be on stdin.
Copyright © 2011, Aaron Blondeau
Drupal theme by Kiwi Themes.