You can use the os.Stat()
function to get the FileInfo structure that contains the information about the file, including the last accessed time.
main.go250 chars19 lines
In the above code, we first use os.Stat()
function to get the fileInfo
structure. Then we use ModTime()
method to get the last accessed time of the file. Finally, we simply print the last accessed time to the console.
gistlibby LogSnag