filerandom

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 4 Imported by: 0

README

File Random

Go Reference

Features

  • Get random files (and open them)
  • Command line ready to use
  • Library that can be integrated in a project

Usage

# Local build
make build
./build/file-random -h

# Remote install
go install github.com/pierrre/file-random/cmd/file-random@latest

# Module install
go get github.com/pierrre/file-random@latest

Documentation

Overview

Package filerandom provides utilities to get random files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	// FSIndex is the index of the filesystem where the file is located.
	FSIndex int
	// Path is the path of the file in the filesystem.
	Path string
}

File represents a file.

type Files

type Files []*File

Files represents a list of files.

func Get

func Get(ctx context.Context, optfs ...Option) (Files, error)

Get returns a Files.

func (Files) GetRandom

func (fps Files) GetRandom() *File

GetRandom returns a random file.

It returns nil if the list of files is empty.

type Option

type Option func(*options)

Option represents an option.

func WithErrorHandler

func WithErrorHandler(f func(context.Context, error)) Option

WithErrorHandler is an Option that defines the error handler.

If it is defined, the error handler is called for each error, otherwise the error is returned.

func WithFSs

func WithFSs(fsyss []fs.FS) Option

WithFSs is an Option that defines the filesystems to scan.

func WithMinSize

func WithMinSize(minSize int64) Option

WithMinSize is an Option that defines the minimum file size to consider.

Directories

Path Synopsis
cmd
file-random
Package file-duplicate provides a command line tool to find duplicate files.
Package file-duplicate provides a command line tool to find duplicate files.

Jump to

Keyboard shortcuts

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