utils

package
v0.0.0-...-e098d20 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Byte2String

func Byte2String(bs []int8) string

Byte2String converts a byte array into a string

func CopyMap

func CopyMap(from *map[string]string) map[string]string

CopyMap makes a copy of all elements of a map.

func GetLineByKeyword

func GetLineByKeyword(path string, keyword string) string

GetLineByKeyword reads a file, searches for the keyword and returns the matched line. It returns empty string "" if no match found or failed to open the path. Pass an empty string "" if you just need to get the first line.

func GetStrByKeyword

func GetStrByKeyword(path string, keyword string) string

GetStrByKeyword read a file, searches for the keyword and returns the matched line with trailing line-feed character trimmed.

func GetStrByKeywordFiles

func GetStrByKeywordFiles(pathes []string, keyword string) (path string, line string)

GetStrByKeywordFiles does the same thing as GetStrByKeyword but searches for a list of files and returns the first matched files and line

func GoVersion

func GoVersion() string

GoVersion returns the Go version

func InstallDir

func InstallDir() string

func InstallTsInSec

func InstallTsInSec() int64

func IsHigherOrEqualGoVersion

func IsHigherOrEqualGoVersion(version string) bool

IsHigherOrEqualGoVersion checks if go version is higher or equal to the given version

func LastRestartInUSec

func LastRestartInUSec() int64

func Max

func Max(x, y int) int

Max returns the greater value

func Min

func Min(x, y int) int

Min returns the lower value

func SPrintBson

func SPrintBson(message []byte) string

SPrintBson prints the BSON message. It's not concurrent-safe and is for testing only

func Version

func Version() string

Version returns the agent's version

Types

type SafeBuffer

type SafeBuffer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SafeBuffer is goroutine-safe buffer. It is for internal test use only.

func (*SafeBuffer) Len

func (b *SafeBuffer) Len() int

func (*SafeBuffer) Read

func (b *SafeBuffer) Read(p []byte) (int, error)

func (*SafeBuffer) Reset

func (b *SafeBuffer) Reset()

Reset truncates the buffer

func (*SafeBuffer) String

func (b *SafeBuffer) String() string

func (*SafeBuffer) Write

func (b *SafeBuffer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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