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
Something interesting
Tutorials
+4.9k HTTP common errors and their meaning explained
+51.9k Golang : How to get time in milliseconds?
+21.1k Golang : For loop continue,break and range
+14.3k Golang : Recombine chunked files example
+8.4k Golang : Generate Datamatrix barcode
+7.5k Golang : How to handle file size larger than available memory panic issue
+12.3k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+6.6k Golang : How to validate ISBN?
+5.4k Golang : Reclaim memory occupied by make() example
+33.6k Golang : How to check if slice or array is empty?
+32.1k Golang : Validate email address with regular expression
+5.4k Unix/Linux : How to archive and compress entire directory ?