Go:无法在go例程中创建服务器

When trying to ListenAndServer inside a go routine I get an error:

package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    http.HandleFunc("/static/", myHandler)
    go func() {
        http.ListenAndServe("localhost:80", nil)
    }()

    fmt.Printf("we are here")
    resp, _ := http.Get("localhost:80/static")

    ans, _ := ioutil.ReadAll(resp.Body)
    fmt.Printf("response: %s", ans)
}

func myHandler(rw http.ResponseWriter, req *http.Request) {
    fmt.Printf(req.URL.Path)
}

The error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x48 pc=0x401102]

goroutine 1 [running]:
panic(0x6160c0, 0xc0420080a0)
        c:/go/src/runtime/panic.go:500 +0x1af
main.main()
        C:/gowork/src/exc/14.go:20 +0xc2
exit status 2

All I want is to create an http server. And then test it and connect to it from the code. What's wrong with Go? (or with me?)

You must use (with "http://" in this case)

resp, _ := http.Get("http://localhost:80/static")

and check the errors before use the response, just in case the request fails

resp, err := http.Get("http://localhost:80/static")
if err != nil {
    // do something
} else {
    ans, _ := ioutil.ReadAll(resp.Body)
    fmt.Printf("response: %s", ans)
}

Also, if you want to get any response from your handler, you have to write a response in it.

func myHandler(rw http.ResponseWriter, req *http.Request) {
    fmt.Printf(req.URL.Path)
    rw.Write([]byte("Hello World!"))
}