package urlenc import "strings" import "fmt" type Pair[V any] struct { Name string Value V } func (a Pair[V]) String() string { return fmt.Sprintf("%s=%v", a.Name, a.Value) } type Array[V any] struct { Name string Values []V } func (a Array[V]) String() string { var b strings.Builder for i, v := range a.Values { fmt.Fprintf(&b, "%s[%d]=%v", a.Name, i, v) if i < len(a.Values) - 1 { fmt.Fprint(&b, "&") } } return b.String() } func Join(values ...any) string { vs := make([]string, len(values)) for i, v := range values { vs[i] = fmt.Sprintf("%s", v) } return strings.Join(vs, "&") }