go: mime.TypeByExtension('.txt') does not return the expected value
The expected output from the program below is text/plain.
I discovered this because the ServeContent (net/http) was returning Content-Type: text/html
for a file with the txt extension that includes HTML tags.
garden:~/mimetest$ uname -a
Linux garden 4.4.68-0-grsec #1-Alpine SMP Fri May 19 08:50:21 GMT 2017 i686 Linux
garden:~/mimetest$ cat /etc/alpine-release
3.13.2
garden:~/mimetest$ cat mimetest.go
package main
import "path/filepath"
import "fmt"
import "mime"
func main() {
name := "x.txt"
ext := filepath.Ext(name);
fmt.Printf("mime type for extension '%s' = %v\n", ext, mime.TypeByExtension(ext))
}
garden:~/mimetest$ go build && ./mimetest
mime type for extension '.txt' =
garden:~/mimetest$ cat /etc/apk/repositories
#/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/v3.13/main
http://dl-cdn.alpinelinux.org/alpine/v3.13/community
#http://dl-cdn.alpinelinux.org/alpine/edge/main
#http://dl-cdn.alpinelinux.org/alpine/edge/community
http://dl-cdn.alpinelinux.org/alpine/edge/testing