Skip to content

Commit

Permalink
glog: make zero value of vModuleFlag usable
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
chressie authored and stapelberg committed Mar 17, 2023
1 parent 2cef961 commit 9c9801e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions glog_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ func (l *Level) Set(value string) error {
type vModuleFlag struct{ *verboseFlags }

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

Expand Down

0 comments on commit 9c9801e

Please sign in to comment.