1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-11-21 16:05:40 +00:00

xattr: fix the failure on empty list

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-07-26 13:55:25 -04:00
parent ed6b293839
commit 2685cd3cc5

View file

@ -29,7 +29,14 @@ func List(path string) ([]string, error) {
if err != nil {
return nil, err
}
return strings.Split(strings.TrimRight(string(dest[:i]), nilByte), nilByte), nil
// If the returned list is empty, return nil instead of []string{""}
str := string(dest[:i])
if str == "" {
return nil, nil
}
return strings.Split(strings.TrimRight(str, nilByte), nilByte), nil
}
const nilByte = "\x00"