utils

package
v0.0.0-...-5a94a59 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(out io.Writer, in io.Reader)

func FormatCommas

func FormatCommas(num int64) string

func FormatHTTPRange

func FormatHTTPRange(offset int64, length int64) string

func HaveReadPermission

func HaveReadPermission(path string) bool

func IsDatabaseFile

func IsDatabaseFile(path string) bool

func NormalFile

func NormalFile(info os.FileInfo) bool

return true if and only if the provided FileInfo represents a completely normal file, and nothing weird like a directory, symlink, pipe, socket, block device, etc

func ReadCloserToReader

func ReadCloserToReader(in io.ReadCloser) io.Reader

do you find it annoying to have to close your readers? this function is for you

func ReaderToReadCloser

func ReaderToReadCloser(in io.Reader) io.ReadCloser

func SliceToArr

func SliceToArr(in []byte) [32]byte

func WalkFiles

func WalkFiles(startPath string, fn func(path string, info os.FileInfo))

walk a directory recursively, but only call the provided function for normal files that don't error on os.Stat

Types

type EmptyReadCloser

type EmptyReadCloser struct{}

func (*EmptyReadCloser) Close

func (erc *EmptyReadCloser) Close() error

func (*EmptyReadCloser) Read

func (erc *EmptyReadCloser) Read(p []byte) (int, error)

type HasherSizer

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

func NewMD5HasherSizer

func NewMD5HasherSizer() HasherSizer

func NewSHA256HasherSizer

func NewSHA256HasherSizer() HasherSizer

func (*HasherSizer) Hash

func (hs *HasherSizer) Hash() []byte

func (*HasherSizer) HashAndSize

func (hs *HasherSizer) HashAndSize() ([]byte, int64)

func (*HasherSizer) Size

func (hs *HasherSizer) Size() int64

func (*HasherSizer) Write

func (hs *HasherSizer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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