From e68bf6185aef85aae52cd2d9a86a9d8b241623e4 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 5 Jul 2021 09:07:32 +0300 Subject: Implemented text, input and numbered fields and improved structure --- go-src/utils/utils.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 go-src/utils/utils.go (limited to 'go-src/utils') diff --git a/go-src/utils/utils.go b/go-src/utils/utils.go new file mode 100644 index 0000000..673f749 --- /dev/null +++ b/go-src/utils/utils.go @@ -0,0 +1,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) +} -- cgit v1.2.3