-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
37 lines (32 loc) · 698 Bytes
/
Copy pathutils.go
File metadata and controls
37 lines (32 loc) · 698 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
package main
import (
"path"
"strings"
"time"
)
// GetMetafilePath derives the path of a metafile from the regular tasklist's
// path.
func GetMetafilePath(ext string, source string) string {
dir, filename := path.Split(source)
return dir + "." + filename + ext
}
// StripNanoFromTime zeroes the nanosecond field of a time object.
func StripNanoFromTime(t time.Time) time.Time {
return time.Date(
t.Year(),
t.Month(),
t.Day(),
t.Hour(),
t.Minute(),
t.Second(),
0,
time.UTC,
)
}
// EnsureTrailingSlash appends a slash ("/"") to a string if it does end with
// one (plus a newline).
func EnsureTrailingSlash(s *string) {
if !strings.HasSuffix(*s, "/") {
*s += "/"
}
}