强大的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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章