support.go 219 B

123456789101112
  1. package v4l2
  2. import "bytes"
  3. // toGoString encodes C null-terminated string as a Go string
  4. func toGoString(s []byte) string {
  5. null := bytes.Index(s, []byte{0})
  6. if null < 0 {
  7. return ""
  8. }
  9. return string(s[:null])
  10. }