Skip to content

labstack/gommon

master
Switch branches/tags
Code

Latest commit

Previously using `l.SetHeader("")` would panic with:

	--- FAIL: TestEmptyHeader (0.00s)
	panic: runtime error: index out of range [-1] [recovered]
		panic: runtime error: index out of range [-1]

	goroutine 18 [running]:
	github.com/labstack/gommon/log.(*Logger).log(0xc00014e990, 0x1, {0x5fb505, 0xd}, {0x0, 0x0, 0x0})
		/home/martin/src/gommon/log/log.go:394 +0x615
	github.com/labstack/gommon/log.(*Logger).Debugf(...)
		/home/martin/src/gommon/log/log.go:158
	github.com/labstack/gommon/log.TestEmptyHeader(0xc000129860?)
		/home/martin/src/gommon/log/log_test.go:128 +0xb1

This adds a check for that. It also checks if there is any content
before writing a space in the "Text header" else branch so you don't end
up with " my message".
6267eb7

Git stats

Files

Permalink
Failed to load latest commit information.

Gommon GoDoc Coverage Status

Common packages for Go

  • Bytes - Format/parse bytes.
  • Color - Style terminal text.
  • Log - Simple logging.