--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a40222e3-e4b3-4996-8232-045fcff43b77n%40googlegroups.com.
The best way to do it is probably by making an HTTP request and see if it succeeds. In production, it's always a good idea to have a health check endpoint anyways. So some service manager can check if it's alive and restart it if necessary. Or so that a load balancer doesn't send traffic until the service is healthy.
I often call net.Listen directly before calling Serve in a goroutine. That way you can connect to the server's socket immediately even though the server might take a while to get around to serving the request.
Look at how net/http/httptest does it.
On Monday, March 29, 2021 at 9:05:50 PM UTC+2 rog wrote:I often call net.Listen directly before calling Serve in a goroutine. That way you can connect to the server's socket immediately even though the server might take a while to get around to serving the request.It seems this would work as long as the server is not using HTTPS and needs to perform a handshake first?