To find the last accessed date of a csv file in Go, you can make use of the os.Stat
function to get the file information, which includes the file's modification time and access time. Here is an example implementation:
main.go747 chars40 lines
In this example, we first open the csv file using the os.Open
function to obtain a file pointer. We then use the file.Stat
method to obtain the file information which includes the last modification and access times of the file. Finally, we print out the last accessed time of the file in RFC3339 format.
Optionally, you can use the encoding/csv
package to read the contents of the csv file as well.
gistlibby LogSnag