MCPcopy Create free account
hub / github.com/prometheus/procfs / SysctlInts

Method SysctlInts

proc_sys.go:36–51  ·  view source on GitHub ↗
(sysctl string)

Source from the content-addressed store, hash-verified

34}
35
36func (fs FS) SysctlInts(sysctl string) ([]int, error) {
37 fields, err := fs.SysctlStrings(sysctl)
38 if err != nil {
39 return nil, err
40 }
41
42 values := make([]int, len(fields))
43 for i, f := range fields {
44 vp := parsers.NewValueParser(f)
45 values[i] = vp.Int()
46 if err := vp.Err(); err != nil {
47 return nil, fmt.Errorf("%w: field %d in sysctl %s is not a valid int: %w", ErrFileParse, i, sysctl, err)
48 }
49 }
50 return values, nil
51}

Callers 2

TestSysctlIntsFunction · 0.80
TestSysctlIntsErrorFunction · 0.80

Calls 4

SysctlStringsMethod · 0.95
IntMethod · 0.95
ErrMethod · 0.95
NewValueParserFunction · 0.92

Tested by 2

TestSysctlIntsFunction · 0.64
TestSysctlIntsErrorFunction · 0.64