首先在文件夹增加文件web.go

package main
import (
"net/http"
)
func main() {
http.Handle("/", http.FileServer(http.Dir(".")))
http.ListenAndServe(":8080", nil)
}

执行命令运行:

go run web.go

$ go run web.go

然后打开本地的8080端口就可以看到自己文件夹下的所有文件点击可以查看