From df21828d275ec96efc9719d00c135f5db1b66d1a Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 3 Jan 2022 12:37:25 +0100 Subject: [PATCH] content/local: 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 --- content/local/store_bsd.go | 2 +- content/local/store_openbsd.go | 2 +- content/local/store_unix.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/local/store_bsd.go b/content/local/store_bsd.go index 3e6a95674..42fddd341 100644 --- a/content/local/store_bsd.go +++ b/content/local/store_bsd.go @@ -27,7 +27,7 @@ import ( func getATime(fi os.FileInfo) time.Time { if st, ok := fi.Sys().(*syscall.Stat_t); ok { - 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()) } return fi.ModTime() diff --git a/content/local/store_openbsd.go b/content/local/store_openbsd.go index 05d1a1a98..2b58b617b 100644 --- a/content/local/store_openbsd.go +++ b/content/local/store_openbsd.go @@ -27,7 +27,7 @@ import ( func getATime(fi os.FileInfo) time.Time { if st, ok := fi.Sys().(*syscall.Stat_t); ok { - 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()) } return fi.ModTime() diff --git a/content/local/store_unix.go b/content/local/store_unix.go index d60d753cb..efa2eb943 100644 --- a/content/local/store_unix.go +++ b/content/local/store_unix.go @@ -27,7 +27,7 @@ import ( func getATime(fi os.FileInfo) time.Time { if st, ok := fi.Sys().(*syscall.Stat_t); ok { - 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()) } return fi.ModTime()