А
Size: a a a
А
x
x.foo()
сделать foo(x)
?x.foo()
превращается ровно в foo(x)
.I
net/http
. Повесил обработчик на http.HandleFunc("/", handler)
. Но почему он отвечает на любой другой адрес, а не только на корень?I
func main() {
http.HandleFunc("/", handler) // each request calls handler
http.ListenAndServe("127.0.0.1:8080", nil)
}
func handler(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello, world!\n")
}
I
if r.URL.Path != "/"
I
func handler(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
w.WriteHeader(http.StatusNotFound)
return
}
io.WriteString(w, "Hello, world!\n")
}
I
x
NB
C
C
s
s
s
А
s
А