fast-replace/go-fast-replace/internal/pairs/pairs.go

31 lines
478 B
Go

package pairs
import (
"fmt"
"math/rand"
)
func MakePairs(n int) []string {
var pairs []string
for i := 1; i <= n; i++ {
pairs = append(pairs, makeKey(i) + "," + makeValue())
}
return pairs
}
func makeKey(i int) string {
return fmt.Sprintf("%06d", i)
}
func makeValue() string {
var letters = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
var length int = len(letters)
s := make([]rune, 6)
for i := range s {
s[i] = letters[rand.Intn(length)]
}
return string(s)
}