utils

package
v0.0.0-...-a3aa6d0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckDirExisted

func CheckDirExisted(dir string) bool

func CheckError

func CheckError(str string, err error)

func CheckFileExisted

func CheckFileExisted(filename string) bool

func Connect

func Connect(user, password, host, port, key string) (*ssh.Client, error)

func CreateDirectory

func CreateDirectory(dir string) bool

func Datetime2EpochCompact

func Datetime2EpochCompact(ts string) int64

Convert the following DateTime format to epoch: 20190507-221634.23248

func Datetime2EpochFull

func Datetime2EpochFull(ts string) int64

Convert the following DateTime format to epoch: 2019-05-07 22:47:09

func Datetime2EpochNoYear

func Datetime2EpochNoYear(year, str string) int64

Convert the following DateTime format to epoch: I0507 22:47:09.501549

func Datetime2EpochPlain

func Datetime2EpochPlain(ts string) int64

Convert the following DateTime format to epoch: %3|1557778930.317

func Datetime2EpochShort

func Datetime2EpochShort(lastEpoch int64, ts string) int64

Convert the following DateTime format to epoch: 22:47:09.824235

func GetFileModTime

func GetFileModTime(filename string) time.Time

get last modified time

func GetMyIpMap

func GetMyIpMap() map[string]int

Get local ip addresses return a map for better search performance

func Interface2Str

func Interface2Str(inter interface{}) string

func LocalRun

func LocalRun(cmd string) string

func LocalRunIgnoreError

func LocalRunIgnoreError(cmd string) (string, error)

func MatchAnyRegex

func MatchAnyRegex(line string, regexArray []*regexp.Regexp) bool

Return true when match anyone of the regexArray

func RemoveContents

func RemoveContents(dir string) error

func RunCmds

func RunCmds(client *ssh.Client, cmds string) (string, string)

run several commands(separated with ";") one by one on remote server

func RunCmdsIgnoreError

func RunCmdsIgnoreError(client *ssh.Client, cmds string) (string, string)

Run commands that might fail

func RunCmds_async

func RunCmds_async(client *ssh.Client, cmds string, c chan int)

run several commands asynchronously

func Scp

func Scp(user, password, host, port, key, src, dest string) error

Types

type DateTimeType

type DateTimeType int
const (
	Full    DateTimeType = iota // e.g., 2019-05-07 22:47:09
	Compact                     // e.g., 20190507-221634.23248
	NoYear                      // e.g., I/W/E0507 22:16:49.801210
	Short                       // 22:47:09.824235
	Epoch                       // e.g., %3|1557778930.317
	Unknown
)

func CheckDateTimeType

func CheckDateTimeType(str string) DateTimeType

Determin DateTimeType of a certain timestamp Instead of using regex match (which is too time-consuming), just check some chars in the string

Jump to

Keyboard shortcuts

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