utils

package
v0.0.0-...-0c9365a Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfPathExist

func CheckIfPathExist(path string) bool

func CheckIfServiceIsInstalled

func CheckIfServiceIsInstalled(serv string) (bool, error)

CheckIfServiceIsInstalled checks if a service is installed

func CleanString

func CleanString(s string) string

func CreateLogger

func CreateLogger(filename string) *logger.Logger

CreateLogger returns a single instance of a Logger configured to save logs to a rotating file.

func CreatePathIfNotExist

func CreatePathIfNotExist(path string) error

CreatePathIfNotExist creates a specific path if not exist

func DetectLinuxFamily

func DetectLinuxFamily() (string, error)

func DoReq

func DoReq[response any](url string, data []byte, method string, headers map[string]string, config *tls.Config) (response, int, error)

func DownloadFile

func DownloadFile(url string, fileName string) error

DownloadFile downloads a file from a URL and saves it to disk. Returns an error on failure.

func Execute

func Execute(c string, dir string, arg ...string) error

func ExecuteWithResult

func ExecuteWithResult(c string, dir string, arg ...string) (string, bool)

func GetCurrentTime

func GetCurrentTime() string

func GetMyPath

func GetMyPath() (string, error)

GetMyPath returns the directory path where the currently running executable is located. Returns a string representing the directory path, and an error if any error occurs during the process.

func IncrementReconnectDelay

func IncrementReconnectDelay(delay time.Duration, maxReconnectDelay time.Duration) time.Duration

func IsPortOpen

func IsPortOpen(ip, port string) bool

func IsProcessRunning

func IsProcessRunning(processName string) (bool, error)

IsProcessRunning checks if a process is active

func LoadTLSCredentials

func LoadTLSCredentials(crtName string) (*tls.Config, error)

func ReadJson

func ReadJson(fileName string, data interface{}) error

ReadJson reads the json data from the specified file URL and unmarshal it into the provided result interface{}. Returns an error if any error occurs during the process.

func ReadYAML

func ReadYAML(path string, result interface{}) error

ReadYAML reads the YAML data from the specified file URL and deserializes it into the provided result interface{}. Returns an error if any error occurs during the process.

func RemoveLock

func RemoveLock(lockdir string) error

func SetLock

func SetLock(lockdir string) error

func StopProcess

func StopProcess(processName string) error

StopProcess checks if a process is active, if so it stops it

func StopService

func StopService(name string) error

func UninstallService

func UninstallService(name string) error

func Unzip

func Unzip(zipFile, destPath string) error

Unzip function unzip a zip file to a specified destination path

func WriteJSON

func WriteJSON(path string, data interface{}) error

Types

type BeautyLogger

type BeautyLogger struct {
}

func GetBeautyLogger

func GetBeautyLogger() *BeautyLogger

func (*BeautyLogger) PrintBanner

func (b *BeautyLogger) PrintBanner()

func (*BeautyLogger) WriteError

func (b *BeautyLogger) WriteError(msg string, err error)

func (*BeautyLogger) WriteSimpleMessage

func (b *BeautyLogger) WriteSimpleMessage(msg string)

func (*BeautyLogger) WriteSuccessfull

func (b *BeautyLogger) WriteSuccessfull(msg string)

Jump to

Keyboard shortcuts

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