Connect to a socket client in golang


This Content is from Stack Overflow. Question asked by Areej Fatimah

I am using this library in golang to connect to socket server. I have to pass an auth object as server is expecting an object which will authenticate the user, but in this implementation, query seems to take map as a parameter. I get an EOF error while sending the stringified struct to Query as given below:

opts.Query["auth"] = str

I have created a nested structure for that purpose, tried converting struct into byte data using marshal and type casted into string, passed it as key value pair to map but that didn’t seem to work out. Here is how my auth nested struct looks like:


How to send this information with the implementation given below:

opts := &socketio_client.Options{
    Transport: "websocket",
    Query:     make(map[string]string),
opts.Query["user"] = "user"
opts.Query["pwd"] = "pass"
uri := ""

I have provided the link to the library.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?