🔧 Refactor 'RandomValueCycle' and 'getKeyValueGeneratorFunc' functions

This commit is contained in:
2025-05-29 22:10:41 +04:00
parent 23c74bdbb1
commit e567155eb1
2 changed files with 26 additions and 22 deletions

View File

@ -203,19 +203,15 @@ func getKeyValueGeneratorFunc[
isRandom := false
for _, kv := range keyValueSlice {
valuesLen := len(kv.Value)
getValueFunc := func() string { return "" }
if valuesLen == 1 {
getValueFunc = func() string { return kv.Value[0] }
} else if valuesLen > 1 {
getValueFunc = utils.RandomValueCycle(kv.Value, localRand)
if valuesLen := len(kv.Value); valuesLen > 1 {
isRandom = true
}
getKeyValueSlice = append(
getKeyValueSlice,
map[string]func() string{kv.Key: getValueFunc},
map[string]func() string{
kv.Key: utils.RandomValueCycle(kv.Value, localRand),
},
)
}