错误详情
- 想要使用不同的路由规则作为静态文件服务器时,访问不到
127.0.0.1/common
package main import ( "net/http" ) func main() { http.Handle("/common/", http.FileServer(http.Dir("./test"))) http.ListenAndServe(":8080", nil) }
解决
test
目录下没有common
文件夹- 正确的目录结构应该是这样子的
127.0.0.1/common
那么结构如下http.Handle("/common/", http.FileServer(http.Dir("./test")))
----test | ----common | 1.txt