Here we go again...

This commit is contained in:
2025-08-28 21:25:10 +04:00
parent 25d4762a3c
commit 42335c1178
62 changed files with 4579 additions and 4460 deletions

42
pkg/types/param.go Normal file
View File

@@ -0,0 +1,42 @@
package types
import "strings"
type Param KeyValue[string, []string]
type Params []Param
func (params Params) GetValue(key string) *[]string {
for i := range params {
if params[i].Key == key {
return &params[i].Value
}
}
return nil
}
func (params *Params) Append(param Param) {
if item := params.GetValue(param.Key); item != nil {
*item = append(*item, param.Value...)
} else {
*params = append(*params, param)
}
}
func (params *Params) Parse(rawValues ...string) {
for _, rawValue := range rawValues {
params.Append(*ParseParam(rawValue))
}
}
func ParseParam(rawValue string) *Param {
parts := strings.SplitN(rawValue, "=", 2)
switch len(parts) {
case 1:
return &Param{Key: parts[0], Value: []string{""}}
case 2:
return &Param{Key: parts[0], Value: []string{parts[1]}}
default:
return &Param{Key: "", Value: []string{""}}
}
}