utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCRCMismatch = errors.New("crc mismatch")
)

Functions

func Bytes

func Bytes[T int64 | int](b T) string

Bytes convert byte size to human-readable size.

func GetCRC32

func GetCRC32(filePath string, writers ...io.Writer) (uint32, error)

GetCRC32 returns the crc32 checksum of a file.

func GetCRC32Parallel

func GetCRC32Parallel(filePath string, hashThreads int, writers ...io.Writer) (uint32, error)

GetCRC32Parallel returns the crc32 checksum of a file using multiple goroutines.

func IsSSD

func IsSSD(filePath string) bool

IsSSD determines if the storage device of a given file path is an SSD by checking its rotational status. Errors are logged, and false is returned on failure.

func ToStrings

func ToStrings[T ~string](in []T) []string

ToStrings converts a slice of any custom string-like type (T ~string) into a regular []string so it can be used with functions like strings.Join.

Types

type CheckCRC

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

func (CheckCRC) VerifyCRC32

func (c CheckCRC) VerifyCRC32() error

type CheckCRCBuilder

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

func NewCheckCRCBuilder

func NewCheckCRCBuilder(inputFile string, wantCRC uint32) *CheckCRCBuilder

func (*CheckCRCBuilder) Build

func (cb *CheckCRCBuilder) Build() CheckCRC

func (*CheckCRCBuilder) WithHashThreads

func (cb *CheckCRCBuilder) WithHashThreads(i int) *CheckCRCBuilder

func (*CheckCRCBuilder) WithParallelRead

func (cb *CheckCRCBuilder) WithParallelRead(parallelRead bool) *CheckCRCBuilder

func (*CheckCRCBuilder) WithProgressBar

func (cb *CheckCRCBuilder) WithProgressBar(bar progress.Progress) *CheckCRCBuilder

Jump to

Keyboard shortcuts

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