go语言的net/http包的使用非常的简单优雅
(1)服务端
[plain] view plain copy
http.HandleFunc用来注册路径处理函数,会根据给定路径的不同,调用不同的函数
http.ListenAndSercer监听iP与端口,本机IP可以省略不写,仅书写冒号加端口,如http.ListenAndSercer(“:8080”, nil)
路径处理函数,参数必须为w http.ResponseWriter和 req *http.Request且不能有返回值
测试结果:成功
(2)客户端
[plain] view plain copy
测试结果:成功