util

package module
v0.0.0-...-a4afd4c Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: MIT Imports: 28 Imported by: 5

README

util

A set of Go utility libraries

Documentation

Index

Constants

View Source
const GEOIP_URI = "https://ipinfo.io/json"
View Source
const ROOT_MUTEX_DIRECTORY = "/tmp/"

Variables

This section is empty.

Functions

func B64D

func B64D(d string) (data []byte, err error)

func B64E

func B64E(d []byte) string

func Base32Decoder

func Base32Decoder(text string) (string, error)

func Check

func Check(err error)

func CheckIPLocalCIDR

func CheckIPLocalCIDR(ipAddress string) (bool, error)

func CheckN

func CheckN(err error, d string)

func CheckR

func CheckR(err error) error

func CompressStream

func CompressStream(p []byte) ([]byte, error)

Use gzip compression to generate a compressed stream

func CopyFile

func CopyFile(source string, destination string) error

func CreateSqlDatetime

func CreateSqlDatetime() string

* Generate a SQL DATETIME compliant string * https://stackoverflow.com/questions/21648842/output-go-time-in-rfc3339-like-mysql-format

func DeSerialize

func DeSerialize(data []byte, s interface{}) error

func DebugOut

func DebugOut(debug string)

* Standard debug method

func DebugOutHex

func DebugOutHex(debug []byte)

* Prints hex output

func DecompressStream

func DecompressStream(p []byte) ([]byte, error)

Decompression subroutine

func GetCompressedSize

func GetCompressedSize(p []byte) int

func GetLocalIP

func GetLocalIP() (localIP *string, err error)

func GetStdin

func GetStdin() *string

func IntToString

func IntToString(n int) string

func IsAsciiPrintable

func IsAsciiPrintable(s string) bool

func RandInt

func RandInt(min int, max int) int

func RandIntRange

func RandIntRange(min, max int) int

func RandomString

func RandomString(l int) string

func RetErrStr

func RetErrStr(text string) (err error)

* Returns a new error object with the specified prefix

func Serialize

func Serialize(d interface{}) ([]byte, error)

func SimpleDateTime

func SimpleDateTime() string

func Sleep

func Sleep(val time.Duration)

func SleepHours

func SleepHours(val time.Duration)

func SleepSeconds

func SleepSeconds(val time.Duration)

func SynchronizeGlobalMutex

func SynchronizeGlobalMutex(mutexName string) (*filemutex.FileMutex, error)

* This method creates a global object which attempts to synchronize instances of * applications that run concurrently. This application WILL terminate the application * if a lock cannot be acquired, otherwise it will return the appropriate *Filemutex * object and a nil error code

func ThrowN

func ThrowN(d string)

* Throw a panic

func WaitForever

func WaitForever()

Types

type GeoIP

type GeoIP struct {
	IPString    string `json:"ip"`
	Hostname    string `json:"hostname"`
	City        string `json:"city"`
	Region      string `json:"region"`
	CountryCode string `json:"country"`
	Coordinates string `json:"loc"`
	ISP         string `json:"org"`
	Postal      string `json:"postal"`
}

func GetGeoIP

func GetGeoIP() (geoip *GeoIP, err error)

type QueueObject

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

func NewQueue

func NewQueue(load ...interface{}) (Queue *QueueObject)

func (*QueueObject) Array

func (f *QueueObject) Array() []interface{}

* Return a read-only array of the queue

func (*QueueObject) CloseQueue

func (f *QueueObject) CloseQueue()

func (*QueueObject) Index

func (f *QueueObject) Index(c int) interface{}

* References a certain element in the array

func (*QueueObject) Len

func (f *QueueObject) Len() int

* Get the length of the elements

func (*QueueObject) Pop

func (f *QueueObject) Pop() interface{}

func (*QueueObject) Push

func (f *QueueObject) Push(p interface{}) int

* Input: Object that needs to be pushed to the Queue * Output: Number of objects in the array

type StackObject

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

func NewStack

func NewStack(load ...interface{}) *StackObject

func (*StackObject) Push

func (f *StackObject) Push(val interface{}) int

type SystemInfo

type SystemInfo struct {
	/*
	 * Interface MAC/IP addresses, GeoIP Location in a juicy serialized structure,
	 *  and global IP address as reported by "ipinfo.io"
	 */
	GlobalIP *GeoIP
	LocalIP  string

	/* Operating system version/build */
	OSName string

	/* Local host information -- should be universal */
	Hostname string
	Username string

	/* GoInfoObject -- kernel and detailed system info */
	GoInfo *goInfo.GoInfoObject

	/* Windows specific output of "systeminfo" command */
	SystemInfoCommand *string
}

func GetSystemInfo

func GetSystemInfo() (sysinfo *SystemInfo, err error)

Jump to

Keyboard shortcuts

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