Server Current Directory with Go

May 15, 2015 Golang

Snippet

Build a Golang http server that will server the current directory.

Code

package main

import "net/http"

func main() {
    panic(http.ListenAndServe(":8080", http.FileServer(http.Dir("."))))
}

You can build this once or run go install httpserv.go and have access to it as long as your $GOPATH/bin is in your $PATH.


comments powered by Disqus