Fix user name, group name and link count display (#829)
These type assertions for `Stat_t` were changed from `syscall` to
the incorrect `unix` ones in c5bd676
.
Fixes #800.
This commit is contained in:
parent
addb6e243e
commit
2104a501aa
7
os.go
7
os.go
@ -11,6 +11,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
@ -177,7 +178,7 @@ func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func userName(f os.FileInfo) string {
|
func userName(f os.FileInfo) string {
|
||||||
if stat, ok := f.Sys().(*unix.Stat_t); ok {
|
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||||
if u, err := user.LookupId(fmt.Sprint(stat.Uid)); err == nil {
|
if u, err := user.LookupId(fmt.Sprint(stat.Uid)); err == nil {
|
||||||
return fmt.Sprintf("%v ", u.Username)
|
return fmt.Sprintf("%v ", u.Username)
|
||||||
}
|
}
|
||||||
@ -186,7 +187,7 @@ func userName(f os.FileInfo) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func groupName(f os.FileInfo) string {
|
func groupName(f os.FileInfo) string {
|
||||||
if stat, ok := f.Sys().(*unix.Stat_t); ok {
|
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||||
if g, err := user.LookupGroupId(fmt.Sprint(stat.Gid)); err == nil {
|
if g, err := user.LookupGroupId(fmt.Sprint(stat.Gid)); err == nil {
|
||||||
return fmt.Sprintf("%v ", g.Name)
|
return fmt.Sprintf("%v ", g.Name)
|
||||||
}
|
}
|
||||||
@ -195,7 +196,7 @@ func groupName(f os.FileInfo) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func linkCount(f os.FileInfo) string {
|
func linkCount(f os.FileInfo) string {
|
||||||
if stat, ok := f.Sys().(*unix.Stat_t); ok {
|
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||||
return fmt.Sprintf("%v ", stat.Nlink)
|
return fmt.Sprintf("%v ", stat.Nlink)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
Loading…
Reference in New Issue
Block a user