Shuffle shuffles the given string randomly it can be chained on function which return StringManipulation interface
()
| 312 | // Shuffle shuffles the given string randomly |
| 313 | // it can be chained on function which return StringManipulation interface |
| 314 | func (i *input) Shuffle() string { |
| 315 | input := getInput(*i) |
| 316 | rand.Seed(time.Now().Unix()) |
| 317 | |
| 318 | inRune := []rune(input) |
| 319 | rand.Shuffle(len(inRune), func(i, j int) { |
| 320 | inRune[i], inRune[j] = inRune[j], inRune[i] |
| 321 | }) |
| 322 | return string(inRune) |
| 323 | } |
| 324 | |
| 325 | // SnakeCase is variadic function that takes one Param slice of strings named rule |
| 326 | // and it returns passed string in snake case form. Rule param helps to omit character |