fix slice index underrun

This commit is contained in:
Sundog Jones 2021-04-23 12:20:17 -07:00
parent 73a020b239
commit 05ab3c9ed1

View File

@ -194,8 +194,8 @@ func menuHandler(ctx context.Context, conn net.Conn, w *gaio.Watcher) {
} }
if res.Operation == gaio.OpRead && res.Size > 0 && res.Conn == conn { if res.Operation == gaio.OpRead && res.Size > 0 && res.Conn == conn {
log.Printf("received on inChan: conn: %v, buffer size: %v\n", res.Conn.RemoteAddr(), res.Size) log.Printf("received on inChan: conn: %v, buffer size: %v\n", res.Conn.RemoteAddr(), res.Size)
log.Println("menu receive: ", strings.TrimSpace(string(res.Buffer[:res.Size-2]))) log.Println("menu receive: ", strings.TrimSpace(string(res.Buffer[:res.Size-1])))
switch string(strings.TrimSpace(string(res.Buffer[:res.Size-2]))) { switch string(strings.TrimSpace(string(res.Buffer[:res.Size-1]))) {
case "welcome": case "welcome":
welcomeStr, err := screenHandler("welcome", nil) welcomeStr, err := screenHandler("welcome", nil)