-
Notifications
You must be signed in to change notification settings - Fork 4.1k
log: %s semantics different from stdlib for nil pointers #64158
Copy link
Copy link
Closed
Labels
A-loggingIn and around the logging infrastructure.In and around the logging infrastructure.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-server-and-securityDB Server & SecurityDB Server & Security
Description
I've seen this in a log message, resulting from using %s for printing a nil pointer of a type that implements SafeFormatter on a value receiver.
%!s(PANIC=SafeFormatter method: value method github.com/cockroachdb/cockroach/pkg/roachpb.Lease.SafeFormat called using nil *Lease pointer
This is different from what fmt.Printf does for the Stringer interface, where it prints <nil>. If possible, it'd certainly take the <nil>. I've found this thread that might describe how to handle this case in the logging lib: golang/go#20995
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-loggingIn and around the logging infrastructure.In and around the logging infrastructure.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-server-and-securityDB Server & SecurityDB Server & Security