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 <tklauser@distanz.ch>
This commit is contained in:
Tobias Klauser 2022-01-03 12:37:25 +01:00
parent ff7fd4eb2e
commit df21828d27
No known key found for this signature in database
GPG Key ID: 6F5040074CCC0D04
3 changed files with 3 additions and 3 deletions

View File

@ -27,7 +27,7 @@ import (
func getATime(fi os.FileInfo) time.Time { func getATime(fi os.FileInfo) time.Time {
if st, ok := fi.Sys().(*syscall.Stat_t); ok { 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() return fi.ModTime()

View File

@ -27,7 +27,7 @@ import (
func getATime(fi os.FileInfo) time.Time { func getATime(fi os.FileInfo) time.Time {
if st, ok := fi.Sys().(*syscall.Stat_t); ok { 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() return fi.ModTime()

View File

@ -27,7 +27,7 @@ import (
func getATime(fi os.FileInfo) time.Time { func getATime(fi os.FileInfo) time.Time {
if st, ok := fi.Sys().(*syscall.Stat_t); ok { 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() return fi.ModTime()