Skip to content

log: %s semantics different from stdlib for nil pointers #64158

@andreimatei

Description

@andreimatei

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

Metadata

Metadata

Assignees

Labels

A-loggingIn and around the logging infrastructure.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-server-and-securityDB Server & Security

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions