Skip to content

Commit 81fe1be

Browse files
committed
#72 Initialize the ct([]uint8) using make()
1 parent f18d5cc commit 81fe1be

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

rfc5322/date.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func Date(argv1 string) string {
130130
// Time string such as "18:30:22" or other formatted string
131131
if strings.Count(e, ":") == 2 {
132132
// This piece might be a time such as "18:30:22", "3:1:4"
133-
ct := []uint8{}
133+
ct := make([]uint8, 0, 3)
134134
for _, f := range strings.Split(e, ":") {
135135
// Each element(integer) should be greater equal 0 and less equal 60.
136136
cv, nyaan := strconv.ParseUint(f, 10, 8); if nyaan != nil || cv > 60 {
@@ -139,10 +139,8 @@ func Date(argv1 string) string {
139139
}
140140
ct = append(ct, uint8(cv))
141141
}
142-
if len(ct) != 3 {
143-
// This piece does not seem to a time string
144-
return ""
145-
}
142+
if len(ct) != 3 { return "" } // This piece does not seem to a time string
143+
146144
p[4] = fmt.Sprintf("%02d:%02d:%02d", ct[0], ct[1], ct[2])
147145

148146
} else {

0 commit comments

Comments
 (0)