How to use
- github 地址:https://github.com/PolluxLee/GoServer
- 关闭防火墙
- 运行 GoServer.exe,不要关闭命令行窗口
- 将本地文件放到 go 文件根目录的 file 文件夹中即可实现内网共享文件
- 浏览器访问
http://localhost:8080/pollux/
,将localhost替换成本地IP地址
GoServer.go
package main
import (
"log"
"net/http"
"os"
)
func main() {
os.Mkdir("file", 0777)
http.Handle("/pollux/", http.StripPrefix("/pollux/", http.FileServer(http.Dir("file"))))
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}