I am just starting to learn golangs, and I came across something rather strange. When you get an empty array from a call to string.Split, it has a length of one.
Example
package main
import (
"fmt"
"strings"
)
func main() {
test := strings.Split("", ",")
fmt.Println(test)
fmt.Println(len(test))
}
It is output:
[]
1
Why is this? If this is the expected behavior, what is the correct way to check if the array is empty?
thank
source
share