Skip to content

Instantly share code, notes, and snippets.

@hewigovens
Created March 24, 2024 23:47
Show Gist options
  • Save hewigovens/efcdf0eb93ee493e339af1da2ccc47e3 to your computer and use it in GitHub Desktop.
Save hewigovens/efcdf0eb93ee493e339af1da2ccc47e3 to your computer and use it in GitHub Desktop.
Serving files
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
fmt.Println("Serving files in the current directory on port 8080")
http.Handle("/", http.FileServer(http.Dir(".")))
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment