Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attributes: avoid the use of %#v formatting verb #6664

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion attributes/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func str(x any) (s string) {
} else if v, ok := x.(string); ok {
return v
}
return fmt.Sprintf("%#v", x)
return fmt.Sprintf("<%p>", x)
}

// MarshalJSON helps implement the json.Marshaler interface, thereby rendering
Expand Down
16 changes: 8 additions & 8 deletions attributes/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ func ExampleAttributes_String() {
fmt.Println("a7:", a7.String())
fmt.Println("a8:", a8.String())
// Output:
// a1: {"attributes_test.key{}": "<nil>" }
// a2: {"attributes_test.key{}": "<nil>" }
// a3: {"attributes_test.key{}": "(*attributes_test.stringVal)(nil)" }
// a4: {"attributes_test.key{}": "<nil>" }
// a5: {"attributes_test.key{}": "1" }
// a6: {"attributes_test.key{}": "two" }
// a7: {"attributes_test.key{}": "attributes_test.stringVal{s:\"two\"}" }
// a8: {"1": "true" }
// a1: {"<%!p(attributes_test.key={})>": "<nil>" }
// a2: {"<%!p(attributes_test.key={})>": "<nil>" }
// a3: {"<%!p(attributes_test.key={})>": "<0x0>" }
// a4: {"<%!p(attributes_test.key={})>": "<%!p(<nil>)>" }
// a5: {"<%!p(attributes_test.key={})>": "<%!p(int=1)>" }
// a6: {"<%!p(attributes_test.key={})>": "two" }
// a7: {"<%!p(attributes_test.key={})>": "<%!p(attributes_test.stringVal={two})>" }
// a8: {"<%!p(int=1)>": "<%!p(bool=true)>" }
}

// Test that two attributes with the same content are Equal.
Expand Down