From 030679ca07894e40040724dde0e2032485992d32 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 3 Jan 2022 12:38:11 +0100 Subject: [PATCH] fs: use syscall.Timespec.Unix Use the syscall method instead of repeating the type conversions for the syscall.Stat_t Atim/Atimespec members. This also allows to drop the //nolint: unconvert comments. Signed-off-by: Tobias Klauser --- fs/stat_atim.go | 2 +- fs/stat_darwinbsd.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/stat_atim.go b/fs/stat_atim.go index 995bf832..996b9c1a 100644 --- a/fs/stat_atim.go +++ b/fs/stat_atim.go @@ -41,5 +41,5 @@ func StatMtime(st *syscall.Stat_t) syscall.Timespec { // StatATimeAsTime returns st.Atim as a time.Time func StatATimeAsTime(st *syscall.Stat_t) time.Time { - return time.Unix(int64(st.Atim.Sec), int64(st.Atim.Nsec)) //nolint: unconvert // int64 conversions ensure the line compiles for 32-bit systems as well. + return time.Unix(st.Atim.Unix()) } diff --git a/fs/stat_darwinbsd.go b/fs/stat_darwinbsd.go index d05a79fb..dbdb90ec 100644 --- a/fs/stat_darwinbsd.go +++ b/fs/stat_darwinbsd.go @@ -41,5 +41,5 @@ func StatMtime(st *syscall.Stat_t) syscall.Timespec { // StatATimeAsTime returns the access time as a time.Time func StatATimeAsTime(st *syscall.Stat_t) time.Time { - return time.Unix(int64(st.Atimespec.Sec), int64(st.Atimespec.Nsec)) //nolint: unconvert // int64 conversions ensure the line compiles for 32-bit systems as well. + return time.Unix(st.Atimespec.Unix()) }