aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/bytes.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/common/bytes.go b/common/bytes.go
index 910c97d3c..fa457b92c 100644
--- a/common/bytes.go
+++ b/common/bytes.go
@@ -134,3 +134,14 @@ func LeftPadBytes(slice []byte, l int) []byte {
return padded
}
+
+// TrimLeftZeroes returns a subslice of s without leading zeroes
+func TrimLeftZeroes(s []byte) []byte {
+ idx := 0
+ for ; idx < len(s); idx++ {
+ if s[idx] != 0 {
+ break
+ }
+ }
+ return s[idx:]
+}