[tsmon] check if targetTypeFlag has been set.
[tsmon] check if targetTypeFlag has been set.

If a program starts with --help or invalid options, flagset iterates through
all of the registered flags and invokes String() of each of the registered flags
to render the default value of them.

The default value of targetTypeFlag is targetTypeFlag{flags: nil}, and
targetTypeFlag.String() is invoked in the above cases. However, it panics
with "invalid memory access or dereference to nil", because ttf.flags is nil in
the default value of the flag.

This CL fixes the bug by checking if ttf.flags is nil. If it is nil, then return
the name of the DeviceTarget, which is the default target type.

R=62d4e38bb1380f055ec4b899baa75e52af09c5f7@google.com
Bug: 941798
Change-Id: Ib3ec392b557bd5da73e3421ca37bae180c774f2b
Reviewed-on: https://chromium-review.googlesource.com/c/infra/luci/luci-go/+/1797946
Reviewed-by: Paul Wankadia <62d4e38bb1380f055ec4b899baa75e52af09c5f7@google.com>
Commit-Queue: Scott Lee <1dcb292530f82960316cb3d87cd67c3f212b79cb@chromium.org>

luci/luci-go,luci/luci-go,luci/luci-go,luci/luci-go,luci/luci-go,luci/luci-go