From 6edba5b98e7eba30e5dd3af2bf997e6c42719fde Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 6 Sep 2020 22:05:04 -0400 Subject: lib: add FillBytes * lib/str.go (FillBytes): New function. --- lib/str.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib') 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 := "" -- cgit v1.2.3