This gist demonstrates how to test the availability of a TCP endponit using Golang. The following example checks if an endpoint is available and responding to both TCP and TLS connections. To run the example, simply open a command line and execute the following:
$ curl -sSL https://goo.gl/ENx9d8 > tcp-tls-ping.go && go run tcp-tls-ping.go
tcp success
tls success
The program shows that the specified endpoint (defaults to google.com:443
) is available and responding to TCP and TLS connection attempts. To illustrate the error that occurs when an endpoint presents an invalid TLS certificate, execute the following: