aboutsummaryrefslogtreecommitdiff
path: root/go-src/utils.go
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-07-04 16:52:25 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-07-04 16:52:25 +0300
commitd4f404e53fb0ab37ec0ffa95d69902410bfe0368 (patch)
tree1803f4d834e77a6673b0cb3d3b585f43f69d7a0c /go-src/utils.go
parent0992f07eb2c4f1b8619d9a12fd67311c8b3f7ea5 (diff)
downloadctfc-d4f404e53fb0ab37ec0ffa95d69902410bfe0368.tar
ctfc-d4f404e53fb0ab37ec0ffa95d69902410bfe0368.tar.gz
ctfc-d4f404e53fb0ab37ec0ffa95d69902410bfe0368.zip
Started work on go implementation of exercise; Implemented the error box and normal box generators
Diffstat (limited to 'go-src/utils.go')
-rw-r--r--go-src/utils.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/go-src/utils.go b/go-src/utils.go
new file mode 100644
index 0000000..5d60ee9
--- /dev/null
+++ b/go-src/utils.go
@@ -0,0 +1,18 @@
+package main
+
+// 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)
+}