Skip to content

Commit

Permalink
metadata: remove String method (#7372)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley authored Jul 1, 2024
1 parent f199062 commit c9caa9e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
6 changes: 0 additions & 6 deletions metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ func Pairs(kv ...string) MD {
return md
}

// String implements fmt.Stringer to allow metadata to be printed when stored
// in a context. It returns the metadata map as formatted by Go's fmt package.
func (md MD) String() string {
return fmt.Sprint(map[string][]string(md))
}

// Len returns the number of items in md.
func (md MD) Len() int {
return len(md)
Expand Down
20 changes: 0 additions & 20 deletions metadata/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,26 +338,6 @@ func (s) TestAppendToOutgoingContext_FromKVSlice(t *testing.T) {
}
}

func TestStringerMD(t *testing.T) {
for _, test := range []struct {
md MD
want string
}{
{MD{}, "map[]"},
{MD{"k1": []string{}}, "map[k1:[]]"},
{MD{"k1": []string{"v1", "v2"}}, "map[k1:[v1 v2]]"},
{MD{"k1": []string{"v1"}}, "map[k1:[v1]]"},
{MD{"k1": []string{"v1", "v2"}, "k2": []string{}, "k3": []string{"1", "2", "3"}}, "map[k1:[v1 v2] k2:[] k3:[1 2 3]]"},
{MD{"k2": []string{}, "k3": []string{"1", "2", "3"}, "k1": []string{"v1", "v2"}}, "map[k1:[v1 v2] k2:[] k3:[1 2 3]]"},
{MD{"k3": []string{"1", "2", "3"}, "k2": []string{}, "k1": []string{"v1", "v2"}}, "map[k1:[v1 v2] k2:[] k3:[1 2 3]]"},
} {
got := test.md.String()
if got != test.want {
t.Fatalf("Metadata string %q should be %q", got, test.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.
Expand Down

0 comments on commit c9caa9e

Please sign in to comment.