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.
This commit is contained in:
parent
18250311b9
commit
1cbdb26dd1
@ -250,7 +250,7 @@ type stringPtrFlag struct {
|
||||
}
|
||||
|
||||
func (f stringPtrFlag) String() string {
|
||||
if *f.ptr == nil {
|
||||
if f.ptr == nil || *f.ptr == nil {
|
||||
return ""
|
||||
}
|
||||
return **f.ptr
|
||||
|
Loading…
Reference in New Issue
Block a user