From 0d9717df51b172073e933eb5839efd0abdaeb60e Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Mon, 1 Jul 2024 09:08:45 -0700 Subject: [PATCH 1/2] metadata: remove String method --- metadata/metadata.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/metadata/metadata.go b/metadata/metadata.go index 6c01a9b359cc..1e9485fd6e26 100644 --- a/metadata/metadata.go +++ b/metadata/metadata.go @@ -90,21 +90,6 @@ func Pairs(kv ...string) MD { return md } -// String implements the Stringer interface for pretty-printing a MD. -// Ordering of the values is non-deterministic as it ranges over a map. -func (md MD) String() string { - var sb strings.Builder - fmt.Fprintf(&sb, "MD{") - for k, v := range md { - if sb.Len() > 3 { - fmt.Fprintf(&sb, ", ") - } - fmt.Fprintf(&sb, "%s=[%s]", k, strings.Join(v, ", ")) - } - fmt.Fprintf(&sb, "}") - return sb.String() -} - // Len returns the number of items in md. func (md MD) Len() int { return len(md) From 0a107f327a91bf7d8b3b16987f16d5f6b70d2268 Mon Sep 17 00:00:00 2001 From: Doug Fawley Date: Mon, 1 Jul 2024 09:16:48 -0700 Subject: [PATCH 2/2] rm tests --- metadata/metadata_test.go | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/metadata/metadata_test.go b/metadata/metadata_test.go index 6753764b9ba3..fbee086fb919 100644 --- a/metadata/metadata_test.go +++ b/metadata/metadata_test.go @@ -22,7 +22,6 @@ import ( "context" "reflect" "strconv" - "strings" "testing" "time" @@ -339,26 +338,6 @@ func (s) TestAppendToOutgoingContext_FromKVSlice(t *testing.T) { } } -func TestStringerMD(t *testing.T) { - for _, test := range []struct { - md MD - want []string - }{ - {MD{}, []string{"MD{}"}}, - {MD{"k1": []string{}}, []string{"MD{k1=[]}"}}, - {MD{"k1": []string{"v1", "v2"}}, []string{"MD{k1=[v1, v2]}"}}, - {MD{"k1": []string{"v1"}}, []string{"MD{k1=[v1]}"}}, - {MD{"k1": []string{"v1", "v2"}, "k2": []string{}, "k3": []string{"1", "2", "3"}}, []string{"MD{", "k1=[v1, v2]", "k2=[]", "k3=[1, 2, 3]", "}"}}, - } { - got := test.md.String() - for _, want := range test.want { - if !strings.Contains(got, want) { - t.Fatalf("Metadata string %q is missing %q", got, want) - } - } - } -} - // Old/slow approach to adding metadata to context func Benchmark_AddingMetadata_ContextManipulationApproach(b *testing.B) { // TODO: Add in N=1-100 tests once Go1.6 support is removed.