-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.go
More file actions
43 lines (39 loc) · 727 Bytes
/
template.go
File metadata and controls
43 lines (39 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"log"
"os"
"time"
)
func writeTemplate(fn string) {
var filename string
if fn == "" {
dateTime := time.Now()
cDate := dateTime.Format("20060102")
const postfix string = "_ttt.csv"
filename = cDate + postfix
} else {
filename = fn
}
lines := []string{
"# ttt journal file",
"#",
"# hours: 40",
"# delimiter: ",
"# datefmt: 02.01.2006",
"# timefmt: 1504",
"#",
"01.01.2024 0900 1700 Some Job"}
file, err := os.Create(filename)
if err != nil {
log.Fatal(err)
}
defer file.Close()
for _, line := range lines {
_, err := file.WriteString(line + "\n")
if err != nil {
log.Fatal(err)
}
}
fmt.Printf("Template created ...\nHappy time tracking!\n")
}