summaryrefslogtreecommitdiffstats
path: root/lib/str.go
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-09-06 22:05:04 -0400
committerrsiddharth <s@ricketyspace.net>2020-09-06 22:05:04 -0400
commit6edba5b98e7eba30e5dd3af2bf997e6c42719fde (patch)
treea312299b808eb715f2ad06792d0c881be74b0f1a /lib/str.go
parent52f09ad3da9d8d11abef07c85179ac52b5bed842 (diff)
lib: add FillBytes
* lib/str.go (FillBytes): New function.
Diffstat (limited to 'lib/str.go')
-rw-r--r--lib/str.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/str.go b/lib/str.go
index e4df4b4..5ccbd33 100644
--- a/lib/str.go
+++ b/lib/str.go
@@ -14,6 +14,17 @@ func FillStr(a string, l int) string {
return b
}
+func FillBytes(c byte, l int) []byte {
+ if l < 1 {
+ return make([]byte, 0)
+ }
+ bs := make([]byte, l)
+ for i := 0; i < l; i++ {
+ bs[i] = c
+ }
+ return bs
+}
+
// Strip space and newline characters from string.
func stripSpaceChars(s string) string {
ss := ""