summaryrefslogtreecommitdiff
path: root/internal/types/string.go
blob: 5cfed34ee8e4ab70e9cca1588c34fd0d64dbff0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
package types

import "bytes"

// As data comes in from arrays, converted to slices, there will be null-bytes at the end..
func StringValue(byteStr []byte) string {
	idx := bytes.IndexByte(byteStr, 0)
	if idx == -1 {
		return string(byteStr)
	}
	return string(byteStr[:idx])
}