Test Coverage with Integration Tests in go

Basics go test tests packages as it is stated below. > go test -h test [build/test flags] [packages] [build/test flags & test binary flags] So given a package, go test runs both in package tests and outside package tests. > go test github.com/haibin/coverage/person ok github.com/haibin/coverage/person 0.007s To list in package tests, run the following. > go list -f '{{.TestGoFiles}}' github.com/haibin/coverage/person [foo_test.go] To list outside package tests, run the following. [Read More]

tcpKeepAliveListener in go

We can quickly start a http server in go as below. http.ListenAndServe(":8080", nil) It is called ListenAndServe because it creates a TCP listener and passes it to the http server. ln, err := net.Listen("tcp", addr) srv.Serve(ln) The actual implementation in the go standard library uses a tcpKeepAliveListener which wraps the TCP listener. srv.Serve(tcpKeepAliveListener{ln.(*net.TCPListener)}) tcpKeepAliveListener implements the TCP keep-alives which might not be very important because HTTP keep-alives are enabled by default. [Read More]