file

package
v1.10.7 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package file provides file system support, including file system walking

Index

Constants

This section is empty.

Variables

View Source
var (
	SkipDir = filepath.SkipDir
)

Functions

func MimeType

func MimeType(data []byte) (string, string, error)

MimeType returns the mimetype of the data, and returns the mimetype, file extension

Types

type VisitFunc

type VisitFunc func(ctx context.Context, abspath string, relpath string, info fs.FileInfo) error

VisitFunc is a function which is called for each file and folder visited. The function should return an error if the walk should be terminated.

type WalkFS

type WalkFS struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewWalker

func NewWalker(fn VisitFunc) *WalkFS

Create a new walkfs with a given visitor function, which is used for touching each visited file and folder

func (*WalkFS) Count

func (walkfs *WalkFS) Count() int

Count the number of files and folders visited

func (*WalkFS) Exclude

func (walkfs *WalkFS) Exclude(v string) error

Exclude adds a path or file extension exclusion to the indexer. If it begins with a '.' then a file extension exlusion is added, If it begins with a '/' then a path extension exclusion is added. Path and name exclusions are case-sensitive, file extension exclusions are not.

func (*WalkFS) Include

func (walkfs *WalkFS) Include(ext string) error

Include adds a file extension inclusion to the indexer. Path exclusions are case-sensitive, file extension exclusions are not. If no inclusions are added, all files are visited

func (*WalkFS) ShouldVisit

func (walkfs *WalkFS) ShouldVisit(relpath string, info fs.FileInfo) bool

ShouldVisit returns true if a path or file should be visited based on exclusions or else returns false

func (*WalkFS) Walk

func (walkfs *WalkFS) Walk(ctx context.Context, path string) error

Walk will walk a file or folder and visit the function for each

Jump to

Keyboard shortcuts

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