Skip to content

Support String() method on attribute.Value and attribute.KeyValue #7810

@bboreham

Description

@bboreham

Problem Statement

I printed some out for debugging, using fmt.Println, and was surprised to get output like

{offset {2 5111  <nil>}} {len {2 235  <nil>}} {read.duration {4 0 3.291µs <nil>}}

Proposed Solution

Implement the Stringer interface, which fmt looks for - a single method String() string, to output some human-readable version of the data.
This could use the existing Value.Emit method. (suggestion from @pellared)

Alternatives

Could document that anyone looking to print out Value should call Emit().

Prior Art

https://go.dev/doc/effective_go#printing

Additional Context

There is already a method Value.AsString; having both this and String could perhaps be confusing.

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions