if req.URL.Path[len(req.URL.Path)-1] != '/' {
http.Redirect(w, req, req.URL.Path+"/", 301)
return
}
for _, index := range indexs {
fi, err = os.Stat(file + index)
if err != nil {
continue
}
http.ServeFile(w, req, file+index)
return
}
http.NotFound(w, req)
return
}
http.ServeFile(w, req, file)
}
希望本文所述对大家Go语言程序设计有所帮助。










