使用GO导入的Style.css出现MIME错误[重复]

This question already has an answer here:

I just started learning go and 1 of the things I really wanna learn to do is making sites in go. I watched some tutorials for it and making sites worked, but I didn't know how to add styles.

I searched for some examples on the internet and stackoverflow, but couldn't find one that actually worked for me (and stayed simple).

Underneath is the code that I ended up with. But I think I got a new problem now cause in the console it says: error

I tried a lot of solutions that I found on the internet for this but none of them worked so I am pretty sure it is because I imported the css wrongly in go.

Go (functions.go):

package main

import (
    "html/template"
    "net/http"
)

type IndexPage struct {
    Title string
    SubTitle string
}

func indexHandler(w http.ResponseWriter, r *http.Request){
    p := IndexPage{Title: "Pizza site", SubTitle: "everyone loves pizzas"} 
    t, _ := template.ParseFiles("index.html")
    t.Execute(w,p)
}

func main() {

    http.HandleFunc("/", indexHandler)
    http.Handle("/css/", http.FileServer(http.Dir("css")))
    http.ListenAndServe(":8080", nil)
}

Html (index.html):

<html lang="nl">
<head>
  <meta charset="utf-8">
  <title>Pizzaaaaaaa</title>
  <link rel="stylesheet" href="css/style.css" type="text/css">
</head>
<body>
    <article>
        <h1>
            {{ .Title }}
            <span class="subtitle">{{ .SubTitle }}</span>
        </h1>
        <p>Some text</p>
    </article>
</body>
</html>

CSS ( /css/style.css )

*{
    color: rgb(250, 157, 157);
}

FileTree

FileTree

</div>

Your handle return 404 when you try to access css file from this url: /css/*

Change your css handle with this:

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

*You got 'text/plain' because the 404 is a plain text.

You have to add the mime type for css files in your response header.

    if strings.HasSuffix(path, ".css") {
        w.Header().Add("Content-Type", "text/css")
    } 

Or something similar with a variable for multiple different mime types.

EDIT:

Please also check this go lang package to include for better mime type handling:

https://golang.org/pkg/mime/