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:
SeekingBlues 2022-05-12 12:25:50 -04:00 committed by GitHub
parent addb6e243e
commit 2104a501aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

7
os.go
View File

@ -11,6 +11,7 @@ import (
"path/filepath"
"runtime"
"strings"
"syscall"
"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 {
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 {
return fmt.Sprintf("%v ", u.Username)
}
@ -186,7 +187,7 @@ func userName(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 {
return fmt.Sprintf("%v ", g.Name)
}
@ -195,7 +196,7 @@ func groupName(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 ""