utils

package
v0.0.0-...-3bd58ec Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDir

func IsDir(path string) bool

func IsFile

func IsFile(path string) bool

func RandLowerStr

func RandLowerStr(length int) string

func RandLowerUpperNumStr

func RandLowerUpperNumStr(length int) string

func RandNumStr

func RandNumStr(length int) string

func RandStr

func RandStr(length int, lower, upper, number bool) string

func RandUpperStr

func RandUpperStr(length int) string

func RemoveDuplicates

func RemoveDuplicates[T comparable](slice []T) []T

RemoveDuplicates removes all duplicate elements from a slice. It returns a new slice with unique elements. The elements of the slice must be comparable. For example, if the slice contains integers, then they must be able to be compared using the "<" operator. If the slice contains structs, then they must have a field that is comparable. For example:

type Person struct {
    Name string
    Age int
}

If the slice contains pointers to structs, then the pointer's target field must be comparable. For example:

type Person struct {
    Name string
    Age int
}

func (p *Person) Compare(other *Person) bool {
    return p.Age < other.Age
}

In this case, the slice can contain pointers to Person structs, as long as the Age field is comparable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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