Go不会为所有HTML页面呈现CSS元素

I am a novice at go programming. I followed this (https://golang.org/doc/articles/wiki/) tutorial. I wanted to build on top of this a site with multiple pages and CSS elements.

In the main method I used

http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css")))) 

This is my makeHandler function. It is supposed to direct all requests to the correct handler.

func makeHandler( fn func( http.ResponseWriter, *http.Request, string)) http.HandlerFunc{
    return func( w http.ResponseWriter, r *http.Request ){
            //extract page title from request
            //and call the provided handler 'fn'
            m := validPath.FindStringSubmatch(r.URL.Path)
            fmt.Println(m)
            if m == nil{
                    http.NotFound(w,r)
                    return
            }
            fn(w,r,m[2])
    }

}

When I printed 'm', all the requests were prefixed by view (I have a viewHandler that is then called to render the templates).

        http.HandleFunc("/view/", makeHandler(viewHandler))

So if I wanted to view an aboutSite page, the url would have /view/aboutSite which would then be directed to viewHandler.

The issue is that the html templates have CSS links and the links are being prefixed by 'view' as well. So if I had this line of code in my html template

<link rel="stylesheet" href="css/bootstrap.min.css">

makeHandler would receive a 'view' prefixed url. /view/css/bootstrap.min.css

what do I need to add/change so that the CSS elements are rendered?

You need to use absolute paths in the href attribute (i.e. use a path which starts with a /), otherwise the path is treated as relative to the current page leading to the behaviour you are seeing.

So for example:

<link rel="stylesheet" href="/css/bootstrap.min.css">