util

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinAvailableDiskSize - available min 500MB
	MinAvailableDiskSize uint64 = 500 * 1024 * 1024
	// MinMemorySize  - min RAM 2 GB
	MinMemorySize uint64 = 2 * 1000 * 1024 * 1024
	// FullPermission - 0777
	FullPermission os.FileMode = 0777
)

Variables

This section is empty.

Functions

func CheckSystemPrerequisites

func CheckSystemPrerequisites(volume string) error

CheckSystemPrerequisites does checked system to prerequisites.

func CopyDir

func CopyDir(src string, dst string) error

CopyDir copies data from source directory to desctination directory.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies file.

func DappCtrlVersion

func DappCtrlVersion(filename string) string

DappCtrlVersion returns dappctrl version.

func DownloadFile

func DownloadFile(filePath, url string) error

DownloadFile downloads the file.

func ExecuteCommand

func ExecuteCommand(filename string, args ...string) (err error)

ExecuteCommand does executing file.

func ExecuteCommandOutput

func ExecuteCommandOutput(filename string, args ...string) (string, error)

ExecuteCommandOutput does executing file and returns output.

func FreePort

func FreePort(host, port string) (string, error)

FreePort returns available free port number.

func GrantAccess

func GrantAccess(path string) error

GrantAccess grants access to directory.

func Hash

func Hash(s string) string

Hash returns string hash.

func IsServiceStopped

func IsServiceStopped(id string) bool

IsServiceStopped returns service stopped status.

func IsURL

func IsURL(path string) bool

IsURL checks path to url.

func KillProcess

func KillProcess(dir string) error

KillProcess kills all processes at dir path.

func MergeJSONFile

func MergeJSONFile(dstFile, srcFile string, exceptions ...string) error

MergeJSONFile merges two json files.

func ParseVersion

func ParseVersion(s string) int64

ParseVersion returns version number in int64 format.

func RenamePath

func RenamePath(path, folder string) string

RenamePath changes folder name and returns it

func RetryTillSucceed

func RetryTillSucceed(ctx context.Context, f func() error) error

RetryTillSucceed tries execute func till succeed or returns timeout error.

func SelfRemove

func SelfRemove(dir string) error

SelfRemove removes itself execute file.

func TempPath

func TempPath(volume string) string

TempPath creates temporary directory.

func TimeOutInSec

func TimeOutInSec(timeout uint64) time.Duration

TimeOutInSec returns time duration in seconds.

func Unzip

func Unzip(src string, dest string) error

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).

Types

type Addr

type Addr struct {
	Address string
	Host    string
	Port    string
}

Addr type contains address, host and port parameters.

func MatchAddr

func MatchAddr(str string) []Addr

MatchAddr returns matches addr params from text.

type WriteCounter

type WriteCounter struct {
	Label        string
	Processed    uint64
	Total        uint64
	OutputLenght int
}

WriteCounter type is used for download process.

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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