go写一个简单的HTTP服务器

package main
  
import (
        "net/http"
		"fmt"
       )

func main() {
    http.HandleFunc("/",myResponse)
   http.ListenAndServe("127.0.0.1:8888",nil)
}

func myResponse(w http.ResponseWriter,r* http.Request)  {
    w.Write([]byte("<html><center> <font size="40">Hello! I am go service started by Alexander!</font></center></html>"))
	fmt.Println("A client has just visited!")
}


////////////////////////////////////////////////////////////////////////

// package main
 
// import (
//    "fmt"
//    "net/http"
// )
 
// func HelloHandler(w http.ResponseWriter, r *http.Request) {
//    fmt.Fprintf(w, "Hello World")
// }
 
// func main () {
//    http.HandleFunc("/", HelloHandler)
//    http.ListenAndServe(":8080", nil)
// }
原文地址:https://www.cnblogs.com/ezhar/p/14731211.html