github.com/goreleaser/goreleaser@v1.25.1/internal/gio/chtimes.go (about) 1 package gio 2 3 import ( 4 "fmt" 5 "os" 6 "strconv" 7 "time" 8 ) 9 10 // Chtimes applies the given ts to the given path. 11 func Chtimes(path, ts string) error { 12 if ts == "" { 13 return nil 14 } 15 modUnix, err := strconv.ParseInt(ts, 10, 64) 16 if err != nil { 17 return fmt.Errorf("chtimes: %s: %w", path, err) 18 } 19 modTime := time.Unix(modUnix, 0) 20 if err := os.Chtimes(path, modTime, modTime); err != nil { 21 return fmt.Errorf("chtimes: %s: %w", path, err) 22 } 23 return nil 24 }