utils

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Overview

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------

  • Copyright (c) IBAX. All rights reserved.
  • See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------

Index

Constants

This section is empty.

Variables

View Source
var (
	// ReturnCh is chan for returns
	ReturnCh chan string
	// CancelFunc is represents cancel func
	CancelFunc context.CancelFunc
	// DaemonsCount is number of daemons
	DaemonsCount int
)

Functions

func CallMethod

func CallMethod(i any, methodName string) any

CallMethod calls the function by its name

func Caller

func Caller(steps int) string

Caller returns the name of the latest function

func CheckClockDrift

func CheckClockDrift() (bool, error)

checkClockDrift queries an NTP server for clock drifts and warns the user if one large enough is detected.

func CheckSign

func CheckSign(publicKeys [][]byte, forSign []byte, signs []byte, nodeKeyOrLogin bool) (bool, error)

CheckSign checks the signature

func CopyFileContents

func CopyFileContents(src, dst string) error

CopyFileContents copy files

func CreateDirIfNotExists

func CreateDirIfNotExists(dir string, mode os.FileMode) error

func ErrInfo

func ErrInfo(verr any, additionally ...string) error

ErrInfo formats the error message

func ErrInfoFmt

func ErrInfoFmt(err string, a ...any) error

ErrInfoFmt fomats the error message

func GetCurrentDir

func GetCurrentDir() string

GetCurrentDir returns the current directory

func GetHTTPTextAnswer

func GetHTTPTextAnswer(url string) (string, error)

GetHTTPTextAnswer returns HTTP answer as a string

func GetHostPort

func GetHostPort(h string) string

func GetNodeKeys

func GetNodeKeys() (string, string)

GetNodeKeys returns node private key and public key

func GetNodePrivateKey

func GetNodePrivateKey() ([]byte, error)

func GetParent

func GetParent() string

GetParent returns the information where the call of function happened

func IsBanError

func IsBanError(err error) bool

func LockOrDie

func LockOrDie(dir string) *flock.Flock

func MakeDirectory

func MakeDirectory(dir string) error

MakeDirectory makes directory if is not exists

func ShellExecute

func ShellExecute(cmdline string)

ShellExecute runs cmdline

func ShuffleSlice

func ShuffleSlice(slice []string)

func StringInSlice

func StringInSlice(slice []string, v string) bool

func ToSnakeCase

func ToSnakeCase(s string) string

func UUID

func UUID() string

func WithBan

func WithBan(err error) error

Types

type BanError

type BanError struct {
	// contains filtered or unexported fields
}

func (*BanError) Error

func (b *BanError) Error() string

type Clock

type Clock interface {
	Now() time.Time
}

Clock represents interface of clock

type ClockWrapper

type ClockWrapper struct {
}

ClockWrapper represents wrapper of clock

func (*ClockWrapper) Now

func (cw *ClockWrapper) Now() time.Time

Now returns current time

type MockClock

type MockClock struct {
	mock.Mock
}

MockClock is an autogenerated mock type for the Clock type

func (*MockClock) Now

func (_m *MockClock) Now() time.Time

Now provides a mock function with given fields:

Directories

Path Synopsis
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

Jump to

Keyboard shortcuts

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