You have to set the Content-Type header in the response correctly. Without the content type, most browsers will not execute the css. Something like the following should work, but this is essentially just a sketch:
http.HandleFunc("/static/",func(wr http.ResponseWriter,req *http.Request) {
// Determine mime type based on the URL
if req.URL.Path.HasSuffix(".css") {
wr.Header().Set("Content-Type","text/css")
}
http.StripPrefix("/static/", fs)).ServeHTTP(wr,req)
})
1
solved Can’t serve external CSS File in Go webapp