Skip to content

Instantly share code, notes, and snippets.

@roessland
Created July 17, 2014 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roessland/1e925bf89f0ee81446ca to your computer and use it in GitHub Desktop.
Save roessland/1e925bf89f0ee81446ca to your computer and use it in GitHub Desktop.
SImilar to python -m SimpleHTTPServer and node's http-server, only in Go.
//usr/bin/go run $0 $@ ; exit
package main
import (
"fmt"; "log"; "net/http"
)
func main() {
fmt.Println("Serving files in the current directory on port 8002")
http.Handle("/", http.FileServer(http.Dir(".")))
err := http.ListenAndServe(":8002", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment