关于 http: multiple registrations for /xxx/ 错误的解决办法
一、起因
出现错误的情况:
http: multiple registrations for ./
http: multiple registrations for /img/
http: multiple registrations for /xxx/
一般都是因为在所写的Golang代码中,多次注册同一文件路径导致的,比如下面这段代码就会出现这样的报错
func handler(){
http.Handle("/img/", http.FileServer(http.Dir("www")))
}
func main(){
http.HandleFunc("/",handler)
log.Fatal(http.ListenAndServe