Browse Source

Add `ToSliceOfSliceOfStrings` method to `tag` encoder and bump version to v0.10.3

main
mleku 3 months ago
parent
commit
dbdc5d703e
No known key found for this signature in database
  1. 11
      pkg/encoders/tag/tag.go
  2. 21
      pkg/encoders/tag/tags.go
  3. 2
      pkg/version/version

11
pkg/encoders/tag/tag.go

@ -157,6 +157,17 @@ func (t *T) Relay() (key []byte) { @@ -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))

21
pkg/encoders/tag/tags.go

@ -188,3 +188,24 @@ func (s *S) GetTagElement(i int) (t *T) { @@ -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
}

2
pkg/version/version

@ -1 +1 @@ @@ -1 +1 @@
v0.10.2
v0.10.3
Loading…
Cancel
Save