Documentation ¶
Index ¶
- func ParseBool(b string) *bool
- 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 ReadIntFromFile(path string) (int64, error)
- func ReadUintFromFile(path string) (uint64, error)
- func SysReadFile(file string) (string, error)
- type ValueParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParsePInt64s ¶ added in v0.0.4
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 ¶ added in v0.0.6
ReadFileNoStat uses ioutil.ReadAll to read contents of entire file. This is similar to ioutil.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 512kB. For files larger than this, a scanner should be used.
func ReadIntFromFile ¶ added in v0.1.0
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 a simplified ioutil.ReadFile that invokes syscall.Read directly. https://github.com/prometheus/node_exporter/pull/728/files
Note that this function will not read files larger than 128 bytes.
Types ¶
type ValueParser ¶ added in v0.0.3
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 ¶ added in v0.0.3
func NewValueParser(v string) *ValueParser
NewValueParser creates a ValueParser using the input string.
func (*ValueParser) Err ¶ added in v0.0.3
func (vp *ValueParser) Err() error
Err returns the last error, if any, encountered by the ValueParser.
func (*ValueParser) Int ¶ added in v0.0.8
func (vp *ValueParser) Int() int
Int interprets the underlying value as an int and returns that value.
func (*ValueParser) PInt64 ¶ added in v0.0.3
func (vp *ValueParser) PInt64() *int64
PInt64 interprets the underlying value as an int64 and returns a pointer to that value.
func (*ValueParser) PUInt64 ¶ added in v0.0.3
func (vp *ValueParser) PUInt64() *uint64
PUInt64 interprets the underlying value as an uint64 and returns a pointer to that value.