Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

32
pkg/redisv2/tool.go Normal file
View File

@@ -0,0 +1,32 @@
package redisv2
import (
"errors"
"fmt"
)
var ErrUnEvenResults = errors.New("uneven number of results in interface array")
// Except an even number of results in the array
func InterfaceArrayToStringMap(array []interface{})(result map[string]string, err error){
if len(array) %2 != 0 {
err = ErrUnEvenResults
return
}
result = make(map[string]string)
for x := 0; x < len(array); x += 2 {
key, ok := array[x].(string)
if !ok {
err =errors.Join(err, fmt.Errorf("failed to convert key %v to string", array[x]))
continue
}
value, ok := array[x+1].(string)
if !ok {
err =errors.Join(err, fmt.Errorf("failed to convert value %v to string", array[x+1]))
continue
}
result[key] = value
}
return
}