Created
October 5, 2020 19:00
-
-
Save denniskupec/8060f66199cb8ddb283fa2477a7f1c43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
"time" | |
) | |
func main() { | |
for _, name := range os.Args[1:] { | |
info, err := os.Stat(name) | |
if os.IsNotExist(err) { | |
f, err := os.OpenFile(name, os.O_CREATE, 0755) | |
if err != nil { | |
log.Fatal(err) | |
} | |
if err := f.Close(); err != nil { | |
log.Fatal(err) | |
} | |
} else if !info.IsDir() { | |
now := time.Now() | |
if err := os.Chtimes(name, now, now); err != nil { | |
log.Fatal(err) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment