mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
26 lines
337 B
Go
26 lines
337 B
Go
package util
|
|
|
|
import (
|
|
"os"
|
|
"sort"
|
|
)
|
|
|
|
// RootNames returns the result of /*.
|
|
func RootNames() []string {
|
|
f, err := os.Open("/")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
names, err := f.Readdirnames(-1)
|
|
f.Close()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
sort.Strings(names)
|
|
for i, name := range names {
|
|
names[i] = "/" + name
|
|
}
|
|
return names
|
|
}
|