Golang Static File Server

The example below uses gorilla/mux package

package main

import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)

func YourHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Gorilla!\n")
}

func UnauthorizedHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(401)
fmt.Fprintf(w, "401 Unauthorized\n")
}

func NotFoundHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(404)
fmt.Fprintf(w, "404 Not Found\n")
}

func main() {
r := mux.NewRouter()
r.HandleFunc("/", YourHandler)
d := "/static/"
r.HandleFunc(d…