Btw, I have to make a correction to my previous post (see below). This init() doesn't seem to take effect all the time (or at all in some projects). I also tried putting them into TestMain instead inside of my test files with the same "doesn't always work" result (most of the time, it does not detect the level). Must be a combination of t.Parallel() and not calling glog.Flush().
The only that truly works 100% of the time is to insert it into each test method. But that's pretty ugly though.
I am not sure when Golang Tests introduced the -args flag; but, today I was reading the docs again and noticed this new -args flag.
It works!
$ go test -v -args -v 3 -logtostderr true
Target a specific function:
$ go test -cover -v -run TestEventsTableTests -args -v 3 -logtostderr true
Obviously, -cover and -v are optional for tests and you can just get away with:
$ go test -run TestEventsTableTests -args -v 3
^- glog seems to output to stderr anyways, without specifying -logtostderr.
Per the docs, you have to add it to the end of the packages to test if specifying packages:
$ go test -cover -v ./podcast -args -v 3 -logtostderr true