util

package
v0.0.0-...-2c3d6b8 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendAll

func AppendAll(strs ...interface{}) []string

AppendAll appends strings and slice of strings together into slice of strings

func JoinAsString

func JoinAsString[E Joinables](elements []E, sep string) string

JoinAsString joins the Joinables type elements together with string seperator to return string value. Currently, it only has logic for fmt.Stringer alone.

func MapKeys

func MapKeys[K comparable, V any](m map[K]V) []K

MapKeys returns slice of keys from map of any type

func PtrInt

func PtrInt[T constraints.Integer](i T) *T

PtrInt returns the reference to integer of any type

func PtrStr

func PtrStr(s string) *string

PtrStr returns pointer to string

func StrWhitespacesCleanup

func StrWhitespacesCleanup(s string) string

StrWhitespacesCleanup replaces multiple whitespaces/tab/newlines with single whitespace.

func StringSliceToFlatBytes

func StringSliceToFlatBytes(lines []string) []byte

StringSliceToFlatBytes joins string slice together with line feed (LF) character, making it []byte data. LF character in unix systems = 0xa

func StrsWhitespacesCleanup

func StrsWhitespacesCleanup(strs []string) []string

StrsWhitespacesCleanup replaces multiple whitespaces/tab/newlines with single whitespace in all strings are slice

func ToStringers

func ToStringers[T any](elems []T) ([]fmt.Stringer, error)

ToStringers wraps elements of input slice with stringer type, provided, all the elements on input slice should implement fmt.Stringer.

func Whitespace

func Whitespace(n uint) string

Whitespace returns whitespace string of length n

Types

type Joinables

type Joinables interface {
	fmt.Stringer
}

Joinables holds the types which are required to be joined together as string. Currently, it only has fmt.Stringer as required in project.

type NonFileWriter

type NonFileWriter interface {
	io.Writer
}

NonFileWriter is a wrapper over IO writer. This is for registering the interface for mocking.

Jump to

Keyboard shortcuts

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