utils

package
v0.0.0-...-9964dcd Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package utils provides some common utility methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteCountIEC

func ByteCountIEC(b int64) string

ByteCountIEC returns humanized size in IEC (binary) format

func ByteCountSI

func ByteCountSI(b int64) string

ByteCountSI returns humanized size in SI (decimal) format

func DecryptData

func DecryptData(data string) (string, error)

DecryptData decrypts data encrypted using EncryptData

func EncryptData

func EncryptData(data string) (string, error)

EncryptData encrypts data using the given key

func GetDurationAsString

func GetDurationAsString(d time.Duration) string

GetDurationAsString returns a string representation for a time.Duration

func GetIPFromRemoteAddress

func GetIPFromRemoteAddress(remoteAddress string) string

GetIPFromRemoteAddress returns the IP from the remote address. If the given remote address cannot be parsed it will be returned unchanged

func GetTimeAsMsSinceEpoch

func GetTimeAsMsSinceEpoch(t time.Time) int64

GetTimeAsMsSinceEpoch returns unix timestamp as milliseconds from a time struct

func GetTimeFromMsecSinceEpoch

func GetTimeFromMsecSinceEpoch(msec int64) time.Time

GetTimeFromMsecSinceEpoch return a time struct from a unix timestamp with millisecond precision

func IsStringInSlice

func IsStringInSlice(obj string, list []string) bool

IsStringInSlice searches a string in a slice and returns true if the string is found

func IsStringPrefixInSlice

func IsStringPrefixInSlice(obj string, list []string) bool

IsStringPrefixInSlice searches a string prefix in a slice and returns true if a matching prefix is found

func NilIfEmpty

func NilIfEmpty(s string) *string

NilIfEmpty returns nil if the input string is empty

func RemoveDecryptionKey

func RemoveDecryptionKey(encryptData string) string

RemoveDecryptionKey returns encrypted data without the decryption key

func SetUmask

func SetUmask(umask int, configValue string)

SetUmask sets umask on unix systems

Types

type VersionInfo

type VersionInfo struct {
	Version    string `json:"version"`
	BuildDate  string `json:"build_date"`
	CommitHash string `json:"commit_hash"`
}

VersionInfo defines version details

func GetAppVersion

func GetAppVersion() VersionInfo

GetAppVersion returns VersionInfo struct

func (*VersionInfo) GetVersionAsString

func (v *VersionInfo) GetVersionAsString() string

GetVersionAsString returns the string representation of the VersionInfo struct

Jump to

Keyboard shortcuts

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