⚠ This page contains old, outdated, obsolete, … historic or WIP content! No warranties e.g. for correctness!
All 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
If, like me, you occasionally want to transfer some files via http—like the sets for a MirOS installation—but are much too lazy to set up apache, here is a simple web server in nine lines of Go:
package main import ( "log" . "net/http" ) func main() { Handle("/", FileServer(Dir("."))) log.Fatal(ListenAndServe(":8080", nil)) }
It simply exports the current directory via http on port 8080. Neat!