historianutils

package
v0.0.0-...-6e6e7c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package historianutils is a library of common utility functions for Battery Historian processing.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ServiceDumpRE is a regular expression to match the beginning of a service dump.
	ServiceDumpRE = regexp.MustCompile(`^DUMP\s+OF\s+SERVICE\s+(?P<service>\S+):`)
)

Functions

func AbsFloat32

func AbsFloat32(x float32) float32

AbsFloat32 returns the absolute value of a float32 number.

func ErrorsToString

func ErrorsToString(errs []error) string

ErrorsToString converts an array of errors into a newline delimited string.

func GzipCompress

func GzipCompress(uncompressed []byte) ([]byte, error)

GzipCompress compresses byte data.

func MaxInt64

func MaxInt64(a int64, b int64) int64

MaxInt64 returns the higher of a or b.

func ParseDurationWithDays

func ParseDurationWithDays(input string) (int64, error)

ParseDurationWithDays parses a duration string and returns the milliseconds. e.g. 3d1h2m This is the same as Golang's time.ParseDuration, but also handles days. Assumes days are 24 hours, which is not exact but usually good enough for what we care about.

func RunCommand

func RunCommand(name string, args ...string) (string, error)

RunCommand executes the given command and returns the output.

func ScrubPII

func ScrubPII(input string) string

ScrubPII scrubs any part of the string that looks like PII (eg. an email address). From:

com.google.android.apps.plus.content.EsProvider/com.google/john.doe@gmail.com/extra
or
*sync*/com.app.android.conversations/com.app.android.account/Mr. Noogler

To:

com.google.android.apps.plus.content.EsProvider/com.google/XXX@gmail.com/extra
or
*sync*/com.app.android.conversations/com.app.android.account/XXX

func SubexpNames

func SubexpNames(r *regexp.Regexp, s string) (bool, map[string]string)

SubexpNames returns a mapping of the sub-expression names to values if the Regexp successfully matches the string, otherwise, it returns false.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL