Last Updated: February 25, 2016
·
1.671K
· bagwanpankaj

A static file server in Go language

A simple file server in Go. Just compile it and run binaries

//file_serve.go
package main

import "net/http"

func main() {
    http.Handle("/", http.FileServer(http.Dir("./")))
    error := http.ListenAndServe(":9000", nil)
    if error != nil {
        panic(error)
    }
 }

Compile it

go build file_serve.go

It will compile it to machine binaries

Then you can run server in any directory using that binary