Changeset 333 in code for trunk/service.go


Ignore:
Timestamp:
Jun 10, 2020, 2:18:15 PM (5 years ago)
Author:
kl
Message:

service: Handle zero-value in stringPtrFlag.String

FlagSet.PrintDefaults uses reflection to construct a zero value, calls
.String on it, and compares the result with the current flag value to
detect zero-value flags. For stringPtrFlag, this would result in a
panic, as String() always dereferenced the first level of its string.

Add another check so that both pointer levels are nil-checked.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/service.go

    r329 r333  
    251251
    252252func (f stringPtrFlag) String() string {
    253         if *f.ptr == nil {
     253        if f.ptr == nil || *f.ptr == nil {
    254254                return ""
    255255        }
Note: See TracChangeset for help on using the changeset viewer.