ebpf_exporter

Форк
0
25 строк · 565.0 Байт
1
package decoder
2

3
import (
4
	"github.com/cloudflare/ebpf_exporter/v2/config"
5
)
6

7
// String is a decoder that decodes strings coming from the kernel
8
type String struct{}
9

10
// Decode transforms byte slice from the kernel into string
11
func (s *String) Decode(in []byte, _ config.Decoder) ([]byte, error) {
12
	return in[0:clen(in)], nil
13
}
14

15
// clen returns position of the fist null byte in a byte slice or byte slice
16
// length if there is no null byte in the slice
17
func clen(n []byte) int {
18
	for i := 0; i < len(n); i++ {
19
		if n[i] == 0 {
20
			return i
21
		}
22
	}
23

24
	return len(n)
25
}
26

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.