diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-11 23:43:52 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-11 23:43:52 +0800 |
commit | 61bf29be36a6678ba16c457229ca306339ea4ebc (patch) | |
tree | 6d765d41b48bbc41165491b1a4dc7b74ad7258ae | |
parent | 58909117bea6a8185df3335300426b8a49542235 (diff) | |
download | go-tangerine-61bf29be36a6678ba16c457229ca306339ea4ebc.tar.gz go-tangerine-61bf29be36a6678ba16c457229ca306339ea4ebc.tar.zst go-tangerine-61bf29be36a6678ba16c457229ca306339ea4ebc.zip |
Check length of timestring before taking slice
-rw-r--r-- | logger/types.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/logger/types.go b/logger/types.go index d98f0874a..0f70578ba 100644 --- a/logger/types.go +++ b/logger/types.go @@ -8,7 +8,12 @@ import ( type utctime8601 struct{} func (utctime8601) MarshalJSON() ([]byte, error) { - return []byte(`"` + time.Now().UTC().Format(time.RFC3339Nano)[:26] + `Z"`), nil + timestr := time.Now().UTC().Format(time.RFC3339Nano) + // Bounds check + if len(timestr) > 26 { + timestr = timestr[:26] + } + return []byte(`"` + timestr + `Z"`), nil } type JsonLog interface { |