Skip to content

Commit

Permalink
attributes: avoid the use of %#v formatting verb (grpc#6664)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars authored Sep 26, 2023
1 parent 147bd85 commit 5e4402f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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

0 comments on commit 5e4402f

Please sign in to comment.