From a26cfccd19389aae72aef96d48e15f5d1b7fcc9f Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 2 Aug 2018 00:33:11 -0600 Subject: [PATCH] bugfix message history --- chatserver.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/chatserver.go b/chatserver.go index e860090..ed848b3 100644 --- a/chatserver.go +++ b/chatserver.go @@ -744,7 +744,6 @@ func main() { broadcastMsg = make(chan myMsg, 128) // Poor-Man's container/ring (circular buffer) myChatHist.msgs = make([]*myMsg, 128) - msgIndex := 0 var addr string if 0 != int(*port) { @@ -854,7 +853,7 @@ func main() { myHttpServer.chans <- bufConn case msg := <-broadcastMsg: // copy comes in, pointer gets saved (and not GC'd, I hope) - myChatHist.msgs[msgIndex] = &msg + myChatHist.msgs[myChatHist.i] = &msg myChatHist.i += 1 if myChatHist.c < cap(myChatHist.msgs) { myChatHist.c += 1