29 lines
413 B
Go
29 lines
413 B
Go
package urlenc
|
|
|
|
import "strings"
|
|
import "fmt"
|
|
|
|
type Builder interface {
|
|
GetValuesURL() []string
|
|
}
|
|
|
|
type Value[V any] struct {
|
|
Name string
|
|
}
|
|
|
|
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()
|
|
}
|
|
|