FileServer

代码

package main

import (
        "io"
        "log"
        "net/http"
)

func main() {
        http.Handle("/dir",http.StripPrefix("/dir", http.FileServer(http.Dir("/usr/local/"))))
        err := http.ListenAndServe(":8080", nil)
        //err := http.ListenAndServe(":8080",http.FileServer(http.Dir("/usr/local/")))
        if err != nil {
                log.Fatal("...")
        }
}

参考

  1. FileServer文档
posted @ 2020-03-15 13:52  星灬期灬五  阅读(280)  评论(0编辑  收藏  举报