FileServer in Go

Posted by GoDoc
Public (Editable by Users)

FileServer returns a handler that serves HTTP requests with the contents of the file system rooted at root.

Go
Edit
package main

import (
	"log"
	"net/http"
)

func main() {
	// Simple static webserver:
	log.Fatal(http.ListenAndServe(":8080", http.FileServer(http.Dir("/usr/share/doc"))))
}