Skip to content

Commit 9c9801e

Browse files
chressiestapelberg
authored andcommitted
glog: make zero value of vModuleFlag usable
The flag package ensures that the zero value of a flag.Value is usable. This commit fixes this. This was raised in https://groups.google.com/g/golang-nuts/c/Atlr8uAjn6U/m/iId17Td5BQAJ. cl/517349579 (google-internal)
1 parent 2cef961 commit 9c9801e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

glog_flags.go

+5
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ func (l *Level) Set(value string) error {
133133
type vModuleFlag struct{ *verboseFlags }
134134

135135
func (f vModuleFlag) String() string {
136+
// Do not panic on the zero value.
137+
// https://groups.google.com/g/golang-nuts/c/Atlr8uAjn6U/m/iId17Td5BQAJ.
138+
if f.verboseFlags == nil {
139+
return ""
140+
}
136141
f.mu.Lock()
137142
defer f.mu.Unlock()
138143

0 commit comments

Comments
 (0)