I have a simple web application, the code file which is named HttpServer.go is:
package main
import (
"net/http"
)
func main() {
mux := http.NewServeMux()
files := http.FileServer(http.Dir("/public"))
mux.Handle("/static/", http.StripPrefix("/static/", files))
server := &http.Server{
Addr: "localhost:8080",
Handler: mux,
}
server.ListenAndServe()
}
I have put the this code file under %GOPATH%/src/first_app, and I go install
this program, the first_app.exe
shows up in %GOPATH%/bin
When I startup the webserver,I accessed
http://localhost:8080/static/a.txt, but 404(NOT FOUND)
complains that a.txt is not found.,
I would ask where should I put the directory public and a.txt