summaryrefslogtreecommitdiff
path: root/configfiles.go
diff options
context:
space:
mode:
Diffstat (limited to 'configfiles.go')
-rw-r--r--configfiles.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/configfiles.go b/configfiles.go
index 4ea72e0..220db76 100644
--- a/configfiles.go
+++ b/configfiles.go
@@ -84,12 +84,14 @@ func readConfigFile(filename string) error {
}
func writeConfigFile() {
- test := time.Now().Format("YYYYMMDD-HH-MM")
- if !writeConfigFileTmp("virtigo.json.new." + test) {
- log.Println("config file write error")
- os.Exit(-1)
- }
- if !writeConfigFileTmp("virtigo.json") {
+ // Get the current time
+ now := time.Now()
+
+ // Format the time to match your desired format: YYYY.MM.DD.HHMMSS
+ timestamp := now.Format("2006.01.02.150405")
+
+ filename := "virtigo.json.new." + timestamp
+ if !writeConfigFileTmp(filename) {
log.Println("config file write error")
os.Exit(-1)
}
@@ -101,10 +103,15 @@ func writeConfigFile() {
log.Printf("rename fail: %s", err)
os.Exit(-1)
}
+
+ if !writeConfigFileTmp("virtigo.json") {
+ log.Println("config file write error")
+ os.Exit(-1)
+ }
}
func writeConfigFileTmp(filename string) bool {
- fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "virtigo.json")
+ fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), filename)
cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666)
defer cfgfile.Close()
if err != nil {