Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bring API to compatibility
  • Loading branch information
atoulme authored Feb 22, 2023
1 parent 31f4ad4 commit 6c1febe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/binary/string_safe.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

package binary

func Str2Bytes(str string) []byte {
return []byte(str)
func Str2Bytes(str string, expectedLen int) []byte {
b := []byte(str)
if len(str) < expectedLen {
extended := make([]byte, expectedLen)
copy(extended, b)
return extended
}

return b
}

0 comments on commit 6c1febe

Please sign in to comment.