To find the creation date of a JSON file in Go, we need to use the os.Stat
function which returns a os.FileInfo
object. This object includes the modifcation time of the file. Here's an example code snippet:
main.go219 chars17 lines
In this example, we use the os.Stat
function to get the os.FileInfo
object that contains details about the file. Then we use the ModTime
method of this object to get the modification time of the file. This modification time will be the creation time if the file has not been modified since it was created.
gistlibby LogSnag