@@ -43,7 +43,7 @@ var month = map[string]time.Month{
4343 "Dec" : time .December ,
4444}
4545
46- var monthIndexed = []time.Month {
46+ var monthIndexed = [... ]time.Month {
4747 0 ,
4848 time .January ,
4949 time .February ,
@@ -117,7 +117,7 @@ func (s *event) SetTimeZone(b []byte) {
117117 }
118118
119119 // +00 +00:00 or +0000
120- // Use second value directly and don't use unecessary time.Duration.
120+ // Use second value directly and don't use unnecessary time.Duration.
121121 // Time.FixedZone accepts number of seconds.
122122 var h , m int
123123 switch len (b [1 :]) {
@@ -137,7 +137,10 @@ func (s *event) SetTimeZone(b []byte) {
137137
138138// SetMonthNumeric sets the month with a number.
139139func (s * event ) SetMonthNumeric (b []byte ) {
140- s .month = monthIndexed [bytesToInt (skipLeadZero (b ))]
140+ month := bytesToInt (skipLeadZero (b ))
141+ if month < len (monthIndexed ) {
142+ s .month = monthIndexed [month ]
143+ }
141144}
142145
143146// SetMonth sets the month.
@@ -211,12 +214,8 @@ func (s *event) Year() int {
211214
212215// SetMessage sets the message.
213216func (s * event ) SetMessage (b []byte ) {
214- // remove BOM
215- if b [0 ] == 0xef && b [1 ] == 0xbb && b [2 ] == 0xbf {
216- s .message = string (b [3 :])
217- } else {
218- s .message = string (b )
219- }
217+ // Trim BOM: https://unicode.org/faq/utf_bom#bom5
218+ s .message = string (bytes .TrimPrefix (b , []byte ("\ufeff " )))
220219}
221220
222221// Message returns the message.
@@ -262,7 +261,7 @@ func (s *event) SetHostname(b []byte) {
262261
263262// Hostname returns the hostname.
264263func (s * event ) Hostname () string {
265- return string ( s .hostname )
264+ return s .hostname
266265}
267266
268267// SetProgram sets the programs as a byte slice.
0 commit comments