如何将切片与字符串进行比较?

package main

import (
    "fmt"
    "net"
)

func main() {

    msg := make([]byte, 1024)

    //Basic variables
    port := ":2002"
    protocol := "udp"

    //Build the address
    myaddr, err := net.ResolveUDPAddr(protocol, port)
    if err != nil {
        fmt.Println("Wrong Address")
        return
    }

    //Output
    fmt.Println("Reading " + protocol + " from " + myaddr.String())

    //Create the connection
    connection, err := net.ListenUDP(protocol, myaddr)
    if err != nil {
        fmt.Println(err)
    }

    //receive msg
    for {
        _, useraddr, err := connection.ReadFromUDP(msg)
        fmt.Println("msg from :", useraddr)

        if err != nil {
            fmt.Printf("Some error  %v", err)
            continue
        }
        go sendResponse(connection, useraddr)
    }
}

This is my UDP server, I'm making a game. So I want, if the client send "let's play", the server to run the go sendresponse function. If it's not "let's play " it will not run.

I think I should compare msg but I don't know how. Thank you :)

Perhaps, something like this:

//receive msg
msg := make([]byte, 1024)
for {
    n, useraddr, err := connection.ReadFromUDP(msg[:cap(msg)])
    msg = msg[:n]
    fmt.Println("msg from :", useraddr)
    if err != nil {
        fmt.Printf("Some error  %v", err)
        continue
    }
    if string(msg) == "let's play" {
        go sendResponse(connection, useraddr)
    }
}

The expression msg[:cap(msg)] sets the msg buffer length to its full capacity.

The statement msg = msg[:n] sets the msg buffer length to the actual length read.

The string(msg) expression converts the msg type []byte to type string for the comparison.