Golang net/http.FileServer() function example

package net/http

Golang net/http.FileServer() function usage example

 package main

 import (
  "net/http"
 )

 func main() {
  http.Handle("/", http.FileServer(http.Dir("./<whatever directory you want to expose>")))
  http.ListenAndServe(":8108", nil)
 }

References :

http://golang.org/pkg/net/http/#FileServer

https://www.socketloop.com/tutorials/golang-simple-file-server

Advertisement