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

This commit is contained in:
Easwar Swaminathan 2023-09-26 09:58:45 -07:00 committed by GitHub
parent 147bd85912
commit 5e4402fffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -127,7 +127,7 @@ func str(x any) (s string) {
} else if v, ok := x.(string); ok { } else if v, ok := x.(string); ok {
return v return v
} }
return fmt.Sprintf("%#v", x) return fmt.Sprintf("<%p>", x)
} }
// MarshalJSON helps implement the json.Marshaler interface, thereby rendering // MarshalJSON helps implement the json.Marshaler interface, thereby rendering

View File

@ -85,14 +85,14 @@ func ExampleAttributes_String() {
fmt.Println("a7:", a7.String()) fmt.Println("a7:", a7.String())
fmt.Println("a8:", a8.String()) fmt.Println("a8:", a8.String())
// Output: // Output:
// a1: {"attributes_test.key{}": "<nil>" } // a1: {"<%!p(attributes_test.key={})>": "<nil>" }
// a2: {"attributes_test.key{}": "<nil>" } // a2: {"<%!p(attributes_test.key={})>": "<nil>" }
// a3: {"attributes_test.key{}": "(*attributes_test.stringVal)(nil)" } // a3: {"<%!p(attributes_test.key={})>": "<0x0>" }
// a4: {"attributes_test.key{}": "<nil>" } // a4: {"<%!p(attributes_test.key={})>": "<%!p(<nil>)>" }
// a5: {"attributes_test.key{}": "1" } // a5: {"<%!p(attributes_test.key={})>": "<%!p(int=1)>" }
// a6: {"attributes_test.key{}": "two" } // a6: {"<%!p(attributes_test.key={})>": "two" }
// a7: {"attributes_test.key{}": "attributes_test.stringVal{s:\"two\"}" } // a7: {"<%!p(attributes_test.key={})>": "<%!p(attributes_test.stringVal={two})>" }
// a8: {"1": "true" } // a8: {"<%!p(int=1)>": "<%!p(bool=true)>" }
} }
// Test that two attributes with the same content are Equal. // Test that two attributes with the same content are Equal.