To find the creation date of a csv file in Go, one can use the os.Stat
function from the os
package.
main.go234 chars16 lines
Here, we import the os
package and use the os.Stat
function to get information about the file. When successful, we print the last modification time of the file. This is because the creation time of a file is not stored in a standard way across all file systems. Instead, we can get the last modification time, which should indicate when the file was created if it has not been modified since then.
Make sure to substitute data.csv
with the name of your csv file.
gistlibby LogSnag