utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToKnownHost

func AddToKnownHost(pemFilePath, publicIp, username string) error

func Contains

func Contains(mapSet map[string]struct{}, item string) bool

func CreateFolder

func CreateFolder(filePath string) error

func CreateFolderIfNotExist

func CreateFolderIfNotExist(filePath string) error

func CreateUniqIdBaseOnUnixTime

func CreateUniqIdBaseOnUnixTime() string

func DownloadFile

func DownloadFile(client *ssh.Client, toFilePath string, fromFilePath string) error

func DurationString

func DurationString(from time.Time) string

func ExistCheck

func ExistCheck(path string) bool

func FirstRuneToLower

func FirstRuneToLower(s string) string

func GenerateSSHKeyPair

func GenerateSSHKeyPair(bits int, privKeyPath, pubKeyPath string) error

GenerateSSHKeyPair generates an RSA SSH key pair of the specified bits.

func GetClient

func GetClient(publicIp, port, username, privateKeyName string) (*ssh.Client, error)

func GetFirstPart

func GetFirstPart(input, delim string) string

func InlineCmd

func InlineCmd(cmdStr string) error

func InlineCmdAsync

func InlineCmdAsync(cmdStr string) error

func InterfaceToString

func InterfaceToString(value interface{}) string

func JoinRootPathWith

func JoinRootPathWith(path string) string

func NilSafeStr added in v0.2.2

func NilSafeStr(o *string) string

func PrintJsonPretty

func PrintJsonPretty(v interface{})

func ReadCSV

func ReadCSV(filename string) (*[][]string, error)

func ReadToString

func ReadToString(path string) (string, error)

func ReplaceAtIndex

func ReplaceAtIndex(from string, newValue string, delim string, index int) (string, error)

replaceAtIndex replaces the value at the specified index in the given from string.

func RootPath

func RootPath() string

func Script

func Script(scriptPath string, envs []string, args ...string) error

func SliceToMap

func SliceToMap(slice []string) map[string]struct{}

func StructToMap

func StructToMap(obj interface{}) map[string]interface{}

func VerifyHost

func VerifyHost(host string, remote net.Addr, key ssh.PublicKey) error

func WritePropertiesFile

func WritePropertiesFile(filePath string, properties map[string]interface{}, emptyOmit bool) error

Types

type Worker

type Worker interface {
	Run()
	Shutdown()
	Action()
}

func NewWorker

func NewWorker(interval time.Duration) Worker

Jump to

Keyboard shortcuts

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