basicdata

package
v0.0.0-...-c4af43d Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileData

type FileData struct {
	// DetectedType records the output of the `file` command run on that file.
	DetectedType string

	// Size records the size of the file (as reported by the filesystem).
	Size int64

	// SHA256 records the SHA256 hashsum of the file.
	SHA256 string

	// LineLengths records the counts of line lengths in the file,
	// where a line is defined as all characters up to a newline.
	LineLengths valuecounts.ValueCounts
}

FileData records various information about a file that can be determined without parsing it using a programming language parser.

func Analyze

func Analyze(ctx context.Context, paths []string, options ...Option) ([]FileData, error)

Analyze collects basic file information for the specified files. Errors are logged rather than returned where possible, to maximise the amount of data collected. Pass instances of Option to control which information is collected.

func (FileData) String

func (bd FileData) String() string

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option allows controlling the behaviour of Analyze with non-required arguments.

func FormatPaths

func FormatPaths(formatPathFunc func(absPath string) string) Option

FormatPaths uses the given function to transform absolute file paths before they are passed to logging.

func SkipLineLengths

func SkipLineLengths() Option

SkipLineLengths disables collecting line length information during analysis, which is useful when the input files are known not to be text files (e.g. a package tarball).

Jump to

Keyboard shortcuts

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