用Go实现 最简单实现 http文件服务器

使用go语言几行代码就实现了http文件服务器,不能再快了。https://download.****.net/my

 

package main

import (
	"fmt"
	"net/http"
)

func main() {
	fmt.Println("hello。。。。")

	http.Handle("/", http.FileServer(http.Dir(".")))
	http.ListenAndServe(":8080", nil)

}

编译生成main.exe  放到你想要的目录下。双击运行

浏览器输入:http://127.0.0.1:8080  效果来了

 

用Go实现 最简单实现 http文件服务器