Answer the question
In order to leave comments, you need to log in
How to concatenate arrays of bytes into one array?
messageReturn := []byte("Your message is: ")+message
fmt.Println(string(message)) //эта строка выводит пустую строку, хотя отправляется текст
if err := conn.WriteMessage(websocket.TextMessage, messageReturn); err != nil {
log.Println(err)
return
}
Answer the question
In order to leave comments, you need to log in
You can use bytes.Buffer (the fastest concatenation) for Go, like this:
messageReturn := bytes.NewBufferString("Your message is: ")
messageReturn.Write(message)
conn.WriteMessage(websocket.TextMessage, messageReturn.Bytes())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question