Skip to content

Instantly share code, notes, and snippets.

@gotnix
Created April 22, 2012 10:52
Show Gist options
  • Save gotnix/2463453 to your computer and use it in GitHub Desktop.
Save gotnix/2463453 to your computer and use it in GitHub Desktop.
Share you directory via http server by golang.
package main
import(
"net/http"
"fmt"
)
func main() {
var (
dir string
port string
)
fmt.Printf("Please input which directory\nwhat you want to share, start with \"/\":\n")
fmt.Scanf("%s",&dir)
h := http.FileServer(http.Dir(dir))
fmt.Printf("Please input port Number: \n")
fmt.Scanf("%s",&port)
http.ListenAndServe(":"+port, h)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment