I have a solution that works, but I want to fine tune it and at the same time understand how it works.
Here is my folder structure:
web/
├── main.go
└── public/
├── css/
├── js/
├── img/
│ └── pict.jpg
└── templates/
The current path that works to get a picture is:
<img src="public/img/pict.jpg"></a>
The desired path to get a picture is (I want to skip the public/ part):
<img src="img/pict.jpg"></a>
The relevant go code:
func main() {
http.HandleFunc("/", index)
http.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir("./public"))))
http.ListenAndServe(":8080", nil)
}
The same short path should also apply on css and js folder. TIA!