golang寫簡單服務器

package main
import (
    "fmt"
    "log"
    "net/http"
)
func sayHello(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "hello world!")
}
func main() {
    http.HandleFunc("/", sayHello)
    err := http.ListenAndServe(":8880", nil)
    if err != nil {
        log.Fatal("ListenAndServe: ", err.Error())
    }
}it

    不用解釋,很是簡單。
import

相關文章
相關標籤/搜索