wisski-cloud-distillery/internal/fsx/touch.go
Tom Wiesing 7b38fdd801
Do a large chunk of the move to go
This commit moves a huge chunk of the code to go. The TODO.md document
indicates what is left to be done.
2022-09-08 14:39:04 +02:00

25 lines
361 B
Go

package fsx
import (
"os"
"time"
)
// Touch touches a file
func Touch(path string) error {
_, err := os.Stat(path)
switch {
case os.IsNotExist(err):
f, err := os.Create(path)
if err != nil {
return err
}
defer f.Close()
return nil
case err != nil:
return err
default:
now := time.Now().Local()
return os.Chtimes(path, now, now)
}
}