i'm trying to send bytes of image data via gorilla/websocket, my current code is :
var b bytes.Buffer
empty := bufio.NewWriter(&b)
png.Encode(empty, img)
err = c.WriteMessage(websocket.TextMessage, b.Bytes())
my code for receiving message :
_, message, err := c.ReadMessage()
if err != nil {
log.Println("read:", err)
return
}
// log.Printf("recv: %s", message)
ioutil.WriteFile("./nani.png", []byte(message), 0644)
then the saved file are corrupted, how do i write/read message as binary/bytes