Skip to content

Commit 030679c

Browse files
committed
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 <[email protected]>
1 parent 44b5ced commit 030679c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/stat_atim.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ func StatMtime(st *syscall.Stat_t) syscall.Timespec {
4141

4242
// StatATimeAsTime returns st.Atim as a time.Time
4343
func StatATimeAsTime(st *syscall.Stat_t) time.Time {
44-
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.
44+
return time.Unix(st.Atim.Unix())
4545
}

fs/stat_darwinbsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ func StatMtime(st *syscall.Stat_t) syscall.Timespec {
4141

4242
// StatATimeAsTime returns the access time as a time.Time
4343
func StatATimeAsTime(st *syscall.Stat_t) time.Time {
44-
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.
44+
return time.Unix(st.Atimespec.Unix())
4545
}

0 commit comments

Comments
 (0)