Using wrong WebSocket protocol returns an “unexpected EOF” error in gorilla/websocket/client.go's Dial function

I was trying to connect to a server in Go by using gorilla/websocket and I kept getting the error "unexpected EOF". It took me way too long to find out it was because I needed to use the secure WebSocket protocol to connect to that server ("wss://" instead of "ws://" in my url).

How can I verify that I'm using the wrong protocol for a given endpoint so that I can log a helpful error message instead of "unexpected EOF"?