2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 10:58:55 +00:00

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
This commit is contained in:
greatroar 2022-11-12 11:40:15 +01:00
parent 05cebc1c4b
commit 60aa87bbab
2 changed files with 2 additions and 10 deletions

View File

@ -4,7 +4,6 @@
package fs package fs
import ( import (
"fmt"
"os" "os"
"syscall" "syscall"
"time" "time"
@ -12,10 +11,7 @@ import (
// extendedStat extracts info into an ExtendedFileInfo for unix based operating systems. // extendedStat extracts info into an ExtendedFileInfo for unix based operating systems.
func extendedStat(fi os.FileInfo) ExtendedFileInfo { func extendedStat(fi os.FileInfo) ExtendedFileInfo {
s, ok := fi.Sys().(*syscall.Stat_t) s := fi.Sys().(*syscall.Stat_t)
if !ok {
panic(fmt.Sprintf("conversion to syscall.Stat_t failed, type is %T", fi.Sys()))
}
extFI := ExtendedFileInfo{ extFI := ExtendedFileInfo{
FileInfo: fi, FileInfo: fi,

View File

@ -4,7 +4,6 @@
package fs package fs
import ( import (
"fmt"
"os" "os"
"syscall" "syscall"
"time" "time"
@ -12,10 +11,7 @@ import (
// extendedStat extracts info into an ExtendedFileInfo for unix based operating systems. // extendedStat extracts info into an ExtendedFileInfo for unix based operating systems.
func extendedStat(fi os.FileInfo) ExtendedFileInfo { func extendedStat(fi os.FileInfo) ExtendedFileInfo {
s, ok := fi.Sys().(*syscall.Stat_t) s := fi.Sys().(*syscall.Stat_t)
if !ok {
panic(fmt.Sprintf("conversion to syscall.Stat_t failed, type is %T", fi.Sys()))
}
extFI := ExtendedFileInfo{ extFI := ExtendedFileInfo{
FileInfo: fi, FileInfo: fi,