From dbdc5d703e968772cfb33690f3c4c33e22ecb656 Mon Sep 17 00:00:00 2001 From: mleku Date: Tue, 7 Oct 2025 15:36:26 +0100 Subject: [PATCH] Add `ToSliceOfSliceOfStrings` method to `tag` encoder and bump version to v0.10.3 --- pkg/encoders/tag/tag.go | 11 +++++++++++ pkg/encoders/tag/tags.go | 21 +++++++++++++++++++++ pkg/version/version | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/pkg/encoders/tag/tag.go b/pkg/encoders/tag/tag.go index 7533383..e76e419 100644 --- a/pkg/encoders/tag/tag.go +++ b/pkg/encoders/tag/tag.go @@ -157,6 +157,17 @@ func (t *T) Relay() (key []byte) { return } +// ToSliceOfStrings returns the tag's bytes slices as a slice of strings. This +// method provides a convenient way to access the tag's contents in string format. +// +// # Return Values +// +// - s ([]string): A slice containing all tag elements converted to strings. +// +// # Expected Behaviour +// +// Returns an empty slice if the tag is empty, otherwise returns a new slice with +// each byte slice element converted to a string. func (t *T) ToSliceOfStrings() (s []string) { for _, v := range t.T { s = append(s, string(v)) diff --git a/pkg/encoders/tag/tags.go b/pkg/encoders/tag/tags.go index fae20fc..a6f7e71 100644 --- a/pkg/encoders/tag/tags.go +++ b/pkg/encoders/tag/tags.go @@ -188,3 +188,24 @@ func (s *S) GetTagElement(i int) (t *T) { t = (*s)[i] return } + +// ToSliceOfSliceOfStrings converts the tag collection into a two-dimensional +// slice of strings, maintaining the structure of tags and their elements. +// +// # Return Values +// +// - ss ([][]string): A slice of string slices where each inner slice represents +// a tag's elements converted from bytes to strings. +// +// - err (error): Currently unused but maintained for interface consistency. +// +// # Expected Behaviour +// +// Iterates through each tag in the collection and converts its byte elements +// to strings, preserving the tag structure in the resulting nested slice. +func (s *S) ToSliceOfSliceOfStrings() (ss [][]string, err error) { + for _, v := range *s { + ss = append(ss, v.ToSliceOfStrings()) + } + return +} diff --git a/pkg/version/version b/pkg/version/version index a30852f..000aadb 100644 --- a/pkg/version/version +++ b/pkg/version/version @@ -1 +1 @@ -v0.10.2 \ No newline at end of file +v0.10.3 \ No newline at end of file