From 60aa87bbabeb3cb3e7abb8b22eae74d0370685ac Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Sat, 12 Nov 2022 11:40:15 +0100 Subject: [PATCH] fs: Remove explicit type check in extendedStat Without comma-ok, the runtime inserts the same check with a similar enough panic message: interface conversion: interface {} is nil, not *syscall.Stat_t --- internal/fs/stat_bsd.go | 6 +----- internal/fs/stat_unix.go | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/internal/fs/stat_bsd.go b/internal/fs/stat_bsd.go index 33a7879f4..11e075b50 100644 --- a/internal/fs/stat_bsd.go +++ b/internal/fs/stat_bsd.go @@ -4,7 +4,6 @@ package fs import ( - "fmt" "os" "syscall" "time" @@ -12,10 +11,7 @@ import ( // extendedStat extracts info into an ExtendedFileInfo for unix based operating systems. func extendedStat(fi os.FileInfo) ExtendedFileInfo { - s, ok := fi.Sys().(*syscall.Stat_t) - if !ok { - panic(fmt.Sprintf("conversion to syscall.Stat_t failed, type is %T", fi.Sys())) - } + s := fi.Sys().(*syscall.Stat_t) extFI := ExtendedFileInfo{ FileInfo: fi, diff --git a/internal/fs/stat_unix.go b/internal/fs/stat_unix.go index bf0d5ceca..c55571031 100644 --- a/internal/fs/stat_unix.go +++ b/internal/fs/stat_unix.go @@ -4,7 +4,6 @@ package fs import ( - "fmt" "os" "syscall" "time" @@ -12,10 +11,7 @@ import ( // extendedStat extracts info into an ExtendedFileInfo for unix based operating systems. func extendedStat(fi os.FileInfo) ExtendedFileInfo { - s, ok := fi.Sys().(*syscall.Stat_t) - if !ok { - panic(fmt.Sprintf("conversion to syscall.Stat_t failed, type is %T", fi.Sys())) - } + s := fi.Sys().(*syscall.Stat_t) extFI := ExtendedFileInfo{ FileInfo: fi,