summaryrefslogtreecommitdiff
path: root/helpers.go
diff options
context:
space:
mode:
authorplutorocks <>2026-02-26 21:30:32 +0000
committerplutorocks <>2026-02-26 21:30:32 +0000
commit3db298ec3eca0ed94cb7912f660df7dd1f4582e0 (patch)
treed406e1d64aa10c8027bf4bf4a5914f1378fb495e /helpers.go
initial commitHEADmaster
Diffstat (limited to 'helpers.go')
-rw-r--r--helpers.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/helpers.go b/helpers.go
new file mode 100644
index 0000000..85f6113
--- /dev/null
+++ b/helpers.go
@@ -0,0 +1,17 @@
+// helpers.go
+package main
+
+// truncateRunes returns at most n runes from s.
+func truncateRunes(s string, n int) string {
+ if n <= 0 {
+ return ""
+ }
+ i := 0
+ for idx := range s {
+ if i == n {
+ return s[:idx]
+ }
+ i++
+ }
+ return s
+} \ No newline at end of file