mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-04 03:11:55 +02:00
b9a08c4dc9
we're repeating this quite a bit Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
25 lines
454 B
Go
25 lines
454 B
Go
package gio
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
// Chtimes applies the given ts to the given path.
|
|
func Chtimes(path, ts string) error {
|
|
if ts == "" {
|
|
return nil
|
|
}
|
|
modUnix, err := strconv.ParseInt(ts, 10, 64)
|
|
if err != nil {
|
|
return fmt.Errorf("chtimes: %s: %w", path, err)
|
|
}
|
|
modTime := time.Unix(modUnix, 0)
|
|
if err := os.Chtimes(path, modTime, modTime); err != nil {
|
|
return fmt.Errorf("chtimes: %s: %w", path, err)
|
|
}
|
|
return nil
|
|
}
|