使用golang的标准库搭建网站--4.关于静态资源处理的问题

mybc724 ·
``` m.exe html/ html/static/ html/index.html ``` ``` index.html: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="author" content="wuqingtao@gmail.com"> <title>当前状态</title> <link href="static/bootstrap/css/bootstrap.min.css" rel="stylesheet"> ...... </head> ...... <html> ``` 如果直接用```http.FileServer(http.Dir("html"))```不是也可以? ``` type Server struct { *http.ServeMux //省略 exit chan int } ``` ``` func Listen(addr string, srv *Server) { //省略 srv.Handle("/", http.FileServer(http.Dir("html"))) log.Fatalln(http.ListenAndServe(addr, srv)) }```
#1