Skip to content

Commit

Permalink
Fix user name, group name and link count display (#829)
Browse files Browse the repository at this point in the history
These type assertions for `Stat_t` were changed from `syscall` to
the incorrect `unix` ones in c5bd676.

Fixes #800.
  • Loading branch information
SeekingBlues authored May 12, 2022
1 parent addb6e2 commit 2104a50
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions os.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path/filepath"
"runtime"
"strings"
"syscall"

"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand All @@ -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 ""
Expand Down

0 comments on commit 2104a50

Please sign in to comment.