document_root.go
package main
import (
"fmt"
"net/http"
"runtime"
)
func main() {
if runtime.GOOS == "windows" {
http.Handle("/", http.FileServer(http.Dir("c:/")))
} else {
http.Handle("/", http.FileServer(http.Dir("/")))
}
fmt.Print("Listening 8080 port")
//http.ListenAndServe(":8080", nil)
http.ListenAndServe("127.0.0.1:8080", nil)
}
ファイル一覧を読み取り専用で取得できる。