Start an http server, the browser visits http://127.0.0.1:8000/go, the page prints hello go.
Source code
package main
import (
"fmt"
"net/http"
)
func myHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "hello go")
}
func main() {
http.HandleFunc("/go", myHandler)
//在指定的地址进行监听,开启一个http
http.ListenAndServe("127.0.0.1:8000", nil)
}