util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RegexpEmail check valid email
	RegexpEmail = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
)
View Source
var StandardFields = log.Fields{
	"hostname": "host-server",
	"appname":  "erebrus",
}

StandardFields for logger

View Source
var StandardFieldsGRPC = log.Fields{
	"hostname": hostname,
	"appname":  "erebrus",
	"service":  "gRPC",
}
View Source
var Version = "1.0"

Erebrus Version

Functions

func BroadcastAddr

func BroadcastAddr(n *net.IPNet) net.IP

BroadcastAddr returns the last address in the given network, or the broadcast address.

func CheckError

func CheckError(message string, err error)

CheckError for checking any errors

func DirectoryExists

func DirectoryExists(name string) bool

DirectoryExists check if directory exists

func FileExists

func FileExists(name string) bool

FileExists check if file exists

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(s int) (string, error)

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GetAvailableIP

func GetAvailableIP(cidr string, reserved []string) (string, error)

GetAvailableIP search for an available ip in cidr against a list of reserved ips

func GetIPFromCidr

func GetIPFromCidr(cidr string) (string, error)

GetIPFromCidr get ip from cidr

func IsIPv6

func IsIPv6(address string) bool

IsIPv6 check if given ip is IPv6

func IsValidCidr

func IsValidCidr(cidr string) bool

IsValidCidr check if CIDR is valid

func IsValidIP

func IsValidIP(ip string) bool

IsValidIP check if ip is valid

func LogError

func LogError(message string, err error)

LogError for logging any errors

func ReadFile

func ReadFile(path string) (bytes []byte, err error)

ReadFile file content

func WriteFile

func WriteFile(path string, bytes []byte) (err error)

WriteFile content to file

Types

This section is empty.

Jump to

Keyboard shortcuts

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