Chtimes in Go

Posted by GoDoc
Public (Editable by Users)

Chtimes changes the access and modification times of the named file, similar to the Unix utime() or utimes() functions.

Go
Edit
package main

import (
	"log"
	"os"
	"time"
)

func main() {
	mtime := time.Date(2006, time.February, 1, 3, 4, 5, 0, time.UTC)
	atime := time.Date(2007, time.March, 2, 4, 5, 6, 0, time.UTC)
	if err := os.Chtimes("some-filename", atime, mtime); err != nil {
		log.Fatal(err)
	}
}