生命不止,继续go go go!!!
从包名就能看到了吧,是golang中提供http的包:
provides HTTP client and server implementations.
先看一个例子:
package main
import "net/http"
func main() {
http.ListenAndServe(":8080", http.FileServer(http.Dir(".")))
}
然后浏览器输入:localhost:8080/main.go
http.FileServer
func FileServer(root FileSystem) Handler
File
Go语言HTTP编程入门指南
本文介绍了Go语言的net/http包,通过实例展示了如何创建HTTP服务器、使用FileServer及监听并处理请求。还提到了ResponseWriter接口和http.Request结构,以及Get、Post等方法,并预告了如何用Go实现简单的RESTful API。
订阅专栏 解锁全文
1万+

被折叠的 条评论
为什么被折叠?



