强大的Go开发服务器简单例子

强大的Go开发服务器简单例子:

packagemain
import"net/http"
funcSayHello(whttp.ResponseWriter,r*http.Request){
    w.Write([]byte("hello"))
}
funcmain(){
    http.HandleFunc("/hello",SayHello())
    http.ListenAndServe(":1234",nil)
}
listenAndServer进行端口的监听
handlefunc进行注册路径的处理函数
处理函数为sayhello

猜你喜欢

转载自www.linuxidc.com/Linux/2016-02/128556.htm