From 02fabe8ee0d05fc22a669b3ba9314aa7ee42b83c Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 22 Nov 2020 12:42:37 -0500 Subject: lib: str: add StrToBytes --- lib/str.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/str.go') diff --git a/lib/str.go b/lib/str.go index 9112a14..c71762c 100644 --- a/lib/str.go +++ b/lib/str.go @@ -25,6 +25,14 @@ func FillBytes(c byte, l int) []byte { return bs } +func StrToBytes(s string) []byte { + bs := make([]byte, len(s)) + for i := 0; i < len(s); i++ { + bs[i] = byte(s[i]) + } + return bs +} + // Strip space and newline characters from string. func stripSpaceChars(s string) string { ss := "" -- cgit v1.2.3