Q:

How does bytes.Split() work on bytes converted from UTF-8 string?

$ cat main.go 
#!/usr/bin/env gorun
// vim: set noexpandtab tabstop=2:

package main

import (
    "fmt"
    "os"
    "bytes"
)

func main() {
    fmt.Printf("%q\n", bytes.Split([]byte(os.Args[1]), []byte(os.Args[2])))
}
$ ./main.go 程序 ''
["程" "序"]

I'd expect that main.go print multple bytes per UTF-8 character. But it just prints the two UTF-8 character 程 and 序.
Could anybody help me understand why it is the case? Thanks.

A:

If sep is empty, Split splits after each UTF-8 sequence.

— the docs.
So although bytes.Split does let you split at arbitrary points and break UTF-8 sequences apart, calling it with a separator of []byte("") won't do so.

