package util
import "github.com/prometheus/procfs/internal/util"
Index ¶
- func ParseBool(b string) *bool
- func ParseHexUint64s(ss []string) ([]*uint64, error)
- func ParsePInt64s(ss []string) ([]*int64, error)
- func ParseUint32s(ss []string) ([]uint32, error)
- func ParseUint64s(ss []string) ([]uint64, error)
- func ReadFileNoStat(filename string) ([]byte, error)
- func ReadHexFromFile(path string) (uint64, error)
- func ReadIntFromFile(path string) (int64, error)
- func ReadUintFromFile(path string) (uint64, error)
- func SysReadFile(file string) (string, error)
- type ValueParser
Functions ¶
func ParseBool ¶
ParseBool parses a string into a boolean pointer.
func ParseHexUint64s ¶
Parses a uint64 from given hex in string.
func ParsePInt64s ¶
ParsePInt64s parses a slice of strings into a slice of int64 pointers.
func ParseUint32s ¶
ParseUint32s parses a slice of strings into a slice of uint32s.
func ParseUint64s ¶
ParseUint64s parses a slice of strings into a slice of uint64s.
func ReadFileNoStat ¶
ReadFileNoStat uses io.ReadAll to read contents of entire file. This is similar to os.ReadFile but without the call to os.Stat, because many files in /proc and /sys report incorrect file sizes (either 0 or 4096). Reads a max file size of 1024kB. For files larger than this, a scanner should be used.
func ReadHexFromFile ¶
ReadHexFromFile reads a file and attempts to parse a uint64 from a hexadecimal format 0xXX.
func ReadIntFromFile ¶
ReadIntFromFile reads a file and attempts to parse a int64 from it.
func ReadUintFromFile ¶
ReadUintFromFile reads a file and attempts to parse a uint64 from it.
func SysReadFile ¶
SysReadFile is here implemented as a noop for builds that do not support the read syscall. For example Windows, or Linux on Google App Engine.
Types ¶
type ValueParser ¶
type ValueParser struct {
// contains filtered or unexported fields
}
A ValueParser enables parsing a single string into a variety of data types in a concise and safe way. The Err method must be invoked after invoking any other methods to ensure a value was successfully parsed.
func NewValueParser ¶
func NewValueParser(v string) *ValueParser
NewValueParser creates a ValueParser using the input string.
func (*ValueParser) Err ¶
func (vp *ValueParser) Err() error
Err returns the last error, if any, encountered by the ValueParser.
func (*ValueParser) Int ¶
func (vp *ValueParser) Int() int
Int interprets the underlying value as an int and returns that value.
func (*ValueParser) PInt64 ¶
func (vp *ValueParser) PInt64() *int64
PInt64 interprets the underlying value as an int64 and returns a pointer to that value.
func (*ValueParser) PUInt64 ¶
func (vp *ValueParser) PUInt64() *uint64
PUInt64 interprets the underlying value as an uint64 and returns a pointer to that value.
Source Files ¶
parse.go readfile.go sysreadfile_compat.go valueparser.go
- Version
- v0.16.1 (latest)
- Published
- Apr 19, 2025
- Platform
- js/wasm
- Imports
- 6 packages
- Last checked
- 5 hours ago –
Tools for package owners.