Serving filesystem content using GO.
Go is a truly wonderful programming language - it allows you to do relatively complex tasks very quickly. The following program will the serve the contents of /home/user
on localhost:9696
. Yes, it really is that simple:
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
port := ":9696";
fmt.Printf("Listening on port: %s", port);
fs := http.FileServer(http.Dir("/home/soda"))
http.Handle("/", http.StripPrefix("/", fs))
log.Fatal(http.ListenAndServe(port, nil))
}