utils

package module
v0.0.0-...-2f8487d Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: GPL-3.0 Imports: 10 Imported by: 12

README

Common utility functions that are shared between some of my go projects.

Currently being used by:

- gomp
- gspot

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	COLORS map[string]string = map[string]string{
		"RESET":  "\033[0m",
		"RED":    "\033[31m",
		"GREEN":  "\033[32m",
		"YELLOW": "\033[33m",
		"BLUE":   "\033[34m",
		"PURPLE": "\033[35m",
		"CYAN":   "\033[36m",
		"GRAY":   "\033[37m",
		"WHITE":  "\033[97m",
	}
)

Functions

func CheckDirectoryFmt

func CheckDirectoryFmt(path string) string

func Copy

func Copy(sourceImage, destinationImage string) error

func DownloadImage

func DownloadImage(url string, imagePath string) (string, error)

func ExpandHomeDir

func ExpandHomeDir(path string) string

func FileExists

func FileExists(path string) bool

func FormatString

func FormatString(a interface{}) string

func GetFontWidth

func GetFontWidth() (float32, float32)

func GetFormattedString

func GetFormattedString(s string, width int) string

func GetMatchedString

func GetMatchedString(a []int, s, color string) string

func GetNetwork

func GetNetwork(ntype, mport, naddress string) (string, string)

func GetWidth

func GetWidth() *winsize

func InsertAt

func InsertAt(inputString, stringTobeInserted string, index int) string

func IsSame

func IsSame[K comparable](a []K, b []K) bool

func MergeMaps

func MergeMaps[K comparable, V any](maps ...map[K]V) map[K]V

func Pop

func Pop[T comparable](index int, a []T) []T

func Print

func Print(color, text string)

func StrTime

func StrTime(e float64) string

func Unique

func Unique(intSlice []int) []int

Types

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func (*Stack[T]) Empty

func (s *Stack[T]) Empty() bool

func (Stack[T]) GetArray

func (s Stack[T]) GetArray() []T

func (*Stack[T]) Pop

func (s *Stack[T]) Pop()

func (*Stack[T]) Push

func (s *Stack[T]) Push(item T)

func (*Stack[T]) Top

func (s *Stack[T]) Top() T

Jump to

Keyboard shortcuts

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