aboutsummaryrefslogtreecommitdiff
path: root/go-src/utils/utils.go
blob: 673f749bb3be9be225c8917f5828075a420d8bc2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package utils

// Repeats a rune given amount of times and returns the result as a string
func RepeatRune(r rune, times int) (result string) {
	for i := 0; i < times; i++ {
		result += string(r)
	}
	return
}

// Replaces a character inside a string with a given rune at index
//
// Thanks https://stackoverflow.com/a/24894202/12036073
func ReplaceAtIndex(in string, r rune, i int) string {
	out := []rune(in)
	out[i] = r
	return string(out)
}