From 3698e5f7fe8e82a0b1edfcc36e4aea3c0824a43e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20L=C3=B6ffel?= Date: Tue, 9 Oct 2018 12:26:46 +0200 Subject: [PATCH] added lock to fix concurrency issue --- recws.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recws.go b/recws.go index 0235d43..aaf3d69 100644 --- a/recws.go +++ b/recws.go @@ -141,9 +141,13 @@ func (rc *RecConn) ReadJSON(v interface{}) error { // (Cookie). Use GetHTTPResponse() method for the response.Header to get // the selected subprotocol (Sec-WebSocket-Protocol) and cookies (Set-Cookie). func (rc *RecConn) Dial(urlStr string, reqHeader http.Header) { + rc.mu.Lock() + defer rc.mu.Unlock() + if urlStr == "" { log.Fatal("Dial: Url cannot be empty") } + u, err := url.Parse(urlStr) if err != nil {