Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

type inference converts "05" to "5" which then isn't usable in strptime()

Aperta
#230 10 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@sevaTechoPark ci sta già lavorando.

Dal 20/5/2019.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug mtail-Language/VM
/^/ +
/(?P<year>\d{4})\/(?P<month>\d{2})\/(?P<day>\d{2}) (?P<time>\d{2}:\d{2}:\d{2}) / +
/.*/ +
/$/ {
    getfilename() !~ /(error\.log)$/ {
        stop
    }

    hidden gauge time_rfc3339
    time_rfc3339 = $year + "-" + $month + "-" + $day + "T" + $time + "Z03:00"
    strptime(time_rfc3339, "2006-01-02T15:04:05Z07:00")

    error_log_count++
}

error.log:

2019/05/14 11:10:05 [warn] ...
2019/05/14 11:11:06 [warn] ...

logfile:

I0514 11:13:15.029268   49162 vm.go:90] nginx.mtail: Runtime error: strptime (2006-01-02T15:04:05Z07:00, 2019-5-14T11:11:06Z03:00, UTC) failed: parsing time "2019-5-14T11:13:15Z03:00": month out of range

I think mtail transform 05 to 5 because think that it is number.

How can I tell to mtail that I wanna regexp numbers but wanna work with string type?


time_rfc3339 = $year + "-" + string($month) + "-" + $day + "T" + $time + "Z03:00"
does not help me

$ mtail -version

mtail version v3.0.0-rc29-12-gc95b546 git revision c95b546631bf7b6077d3377f25aff2d5306d305f go version go1.12.4 go arch amd64 go os freebsd
Lingua principale
Go
Stelle
4k
Fork
394
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.