Some changes, path specific data

This commit is contained in:
Simon Martens
2025-02-18 18:39:30 +01:00
parent 0f32f38b5e
commit 3be64bd10d
19 changed files with 237 additions and 147 deletions

View File

@@ -1,5 +1,24 @@
package functions
import "fmt"
func Arr(els ...any) []any {
return els
}
func Dict(values ...interface{}) (map[string]interface{}, error) {
// Must have even number of args: key, value, key, value, ...
if len(values)%2 != 0 {
return nil, fmt.Errorf("invalid dict call: must have even number of args")
}
m := make(map[string]interface{}, len(values)/2)
for i := 0; i < len(values); i += 2 {
key, ok := values[i].(string)
if !ok {
return nil, fmt.Errorf("dict keys must be strings")
}
m[key] = values[i+1]
}
return m, nil
}