There are a few ways. The most control is via hijacking the connection, the most direct is to close the body of the reader (eg. r.Body.Close()) but the best way is to set the "Connection" header to "close" on your writer.
eg. w.Header().Set("Connection", "close") in the handler func.
If you set this, the http package should close the connection for you after it is done processing your current request. You can and usually should call this up front in your handler, it won't close the connection immediately. I prefer this to trying to manually close the connection because it should work despite the function exit point (sort of like a defer without the defer).
It is probably also worth boosting your fd count, because if you're flooded with connections you still might hit the limit faster than you can close the connections. At the very least you may want to do the sorts of things web servers like apache do: http://httpd.apache.org/docs/2.2/vhosts/fd-limits.html (Setrlimit is available in Go's syscall package and may help you out here).
eg. w.Header().Set("Connection", "close") in the handler func.
If you set this, the http package should close the connection for you after it is done processing your current request. You can and usually should call this up front in your handler, it won't close the connection immediately. I prefer this to trying to manually close the connection because it should work despite the function exit point (sort of like a defer without the defer).
It is probably also worth boosting your fd count, because if you're flooded with connections you still might hit the limit faster than you can close the connections. At the very least you may want to do the sorts of things web servers like apache do: http://httpd.apache.org/docs/2.2/vhosts/fd-limits.html (Setrlimit is available in Go's syscall package and may help you out here).