Skip to content

Commit 5e4402f

Browse files
authored
attributes: avoid the use of %#v formatting verb (grpc#6664)
1 parent 147bd85 commit 5e4402f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

attributes/attributes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func str(x any) (s string) {
127127
} else if v, ok := x.(string); ok {
128128
return v
129129
}
130-
return fmt.Sprintf("%#v", x)
130+
return fmt.Sprintf("<%p>", x)
131131
}
132132

133133
// MarshalJSON helps implement the json.Marshaler interface, thereby rendering

attributes/attributes_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ func ExampleAttributes_String() {
8585
fmt.Println("a7:", a7.String())
8686
fmt.Println("a8:", a8.String())
8787
// Output:
88-
// a1: {"attributes_test.key{}": "<nil>" }
89-
// a2: {"attributes_test.key{}": "<nil>" }
90-
// a3: {"attributes_test.key{}": "(*attributes_test.stringVal)(nil)" }
91-
// a4: {"attributes_test.key{}": "<nil>" }
92-
// a5: {"attributes_test.key{}": "1" }
93-
// a6: {"attributes_test.key{}": "two" }
94-
// a7: {"attributes_test.key{}": "attributes_test.stringVal{s:\"two\"}" }
95-
// a8: {"1": "true" }
88+
// a1: {"<%!p(attributes_test.key={})>": "<nil>" }
89+
// a2: {"<%!p(attributes_test.key={})>": "<nil>" }
90+
// a3: {"<%!p(attributes_test.key={})>": "<0x0>" }
91+
// a4: {"<%!p(attributes_test.key={})>": "<%!p(<nil>)>" }
92+
// a5: {"<%!p(attributes_test.key={})>": "<%!p(int=1)>" }
93+
// a6: {"<%!p(attributes_test.key={})>": "two" }
94+
// a7: {"<%!p(attributes_test.key={})>": "<%!p(attributes_test.stringVal={two})>" }
95+
// a8: {"<%!p(int=1)>": "<%!p(bool=true)>" }
9696
}
9797

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

0 commit comments

Comments
 (0)