mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-12-22 05:46:30 +00:00
xattr: fix the failure on empty list
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
ed6b293839
commit
2685cd3cc5
1 changed files with 8 additions and 1 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue