Skip to content

Commit

Permalink
attributes: let badVerb handle nil
Browse files Browse the repository at this point in the history
  • Loading branch information
searKing committed Sep 19, 2023
1 parent 55f2b24 commit 32abddd
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions attributes/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,8 @@ func (a *Attributes) String() string {
return sb.String()
}

const nilAngleString = "<nil>"

func str(x any) (s string) {
if x == nil { // NOTE: typed nils will not be caught by this check
return nilAngleString
} else if v, ok := x.(fmt.Stringer); ok {
if v, ok := x.(fmt.Stringer); ok {
return fmt.Sprint(v)
} else if v, ok := x.(string); ok {
return v
Expand All @@ -142,6 +138,8 @@ func str(x any) (s string) {
}
}

const nilAngleString = "<nil>"

// badVerb is like fmt.Sprintf("%p", arg), but with
// leading "%!verb(" replaced by "<" and tailing ")" replaced by ">".
// If an invalid argument is given for a '%p', such as providing
Expand Down

0 comments on commit 32abddd

Please sign in to comment.