I have a very basic Go web app which is simply supposed to serve static files from a public sub-folder:
package main
import (
"net/http"
)
func main() {
mux := http.NewServeMux()
fs := http.FileServer(http.Dir("public"))
mux.Handle("/", fs)
http.ListenAndServe(":8181", mux)
}
If I run the app (go run main.go) it starts, but when I visit
localhost:8181/readme.txt
or
localhost:8181/index.html
both of which exist within the public sub folder, I get a 404 error returned. Nothing is logged (that I know of), but I’m at odds to understand why it is not being served.
Any suggestions welcomed.
Thanks