为什么这段Golang代码不起作用?

_, error := connection.Read(buffer)
buffer := make([]byte, BUFFER_SIZE)
splited := strings.Split(string(buffer), " ")
switch splited[0] {
case "TEST":
    connection.Write([]byte("TEST CONNECTION OK"))
    log.Printf("TEST COMMAND")
    break;

If I write "TEST" in client, the server will not enter the case statement. But if I send "TEST SOMETHING" from client, the server will enter it as expected. Is this a bug of go-lang?

Print out your split buffer slice, it still contains the null bytes with which it was initialized:

http://play.golang.org/p/CW45hPBZ-e

buffer := make([]byte, 32)
copy(buffer, []byte("TEST"))

splited := strings.Split(string(buffer), " ")

fmt.Printf("%#v
", splited)

Prints: []string{"TEST\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"}