utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InSlice

func InSlice(v string, sl []string) bool

InSlice checks given string in string slice or not.

func InSliceIface

func InSliceIface(v interface{}, sl []interface{}) bool

InSliceIface checks given interface in interface slice.

func RandomCreateBytes

func RandomCreateBytes(n int, alphabets ...byte) []byte

RandomCreateBytes generate random []byte by specify chars.

func SliceChunk

func SliceChunk(slice []interface{}, size int) (chunkslice [][]interface{})

SliceChunk separates one slice to some sized slice.

func SliceDiff

func SliceDiff(slice1, slice2 []interface{}) (diffslice []interface{})

SliceDiff returns diff slice of slice1 - slice2.

func SliceFilter

func SliceFilter(slice []interface{}, a filtertype) (ftslice []interface{})

SliceFilter generates a new slice after filter function.

func SliceIntersect

func SliceIntersect(slice1, slice2 []interface{}) (diffslice []interface{})

SliceIntersect returns slice that are present in all the slice1 and slice2.

func SliceMerge

func SliceMerge(slice1, slice2 []interface{}) (c []interface{})

SliceMerge merges interface slices to one slice.

func SlicePad

func SlicePad(slice []interface{}, size int, val interface{}) []interface{}

SlicePad prepends size number of val into slice.

func SliceRand

func SliceRand(a []interface{}) (b interface{})

SliceRand returns random one from slice.

func SliceRandList

func SliceRandList(min, max int) []int

SliceRandList generate an int slice from min to max.

func SliceRange

func SliceRange(start, end, step int64) (intslice []int64)

SliceRange generates a new slice from begin to end with step duration of int64 number.

func SliceReduce

func SliceReduce(slice []interface{}, a reducetype) (dslice []interface{})

SliceReduce generates a new slice after parsing every value by reduce function

func SliceShuffle

func SliceShuffle(slice []interface{}) []interface{}

SliceShuffle shuffles a slice.

func SliceSum

func SliceSum(intslice []int64) (sum int64)

SliceSum sums all values in int64 slice.

func SliceUnique

func SliceUnique(slice []interface{}) (uniqueslice []interface{})

SliceUnique cleans repeated values in slice.

func Walk

func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error

Walk walks the file tree rooted at root in filesystem, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn.

Types

type FileSystem

type FileSystem struct {
}

func (FileSystem) Open

func (d FileSystem) Open(name string) (http.File, error)

Jump to

Keyboard shortcuts

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