wc

package
v0.0.0-...-46b2b5f Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LineFlag = "lines"
	ByteFlag = "bytes"
	WordFlag = "words"
	CharFlag = "chars"
	LongFlag = "max-line-length"
)

Variables

This section is empty.

Functions

func BindFlagSet

func BindFlagSet(wo *Options) *pflag.FlagSet

func Main

func Main(options Options) error

Main is the kickoff for the wc program. so it can be compiled stand alone or as a subcommand runs as many workers as CPUs. this probably should be tunable at compile time

func ReadFile

func ReadFile(options Options, fnChan <-chan string, resChan chan<- Results, errChan chan<- error, wg *sync.WaitGroup)

ReadFile from a chan and stream out results. It was a closure over what the arguments are, but I want to pull it out to test

Types

type Options

type Options struct {
	Bytes, Characters, Newlines, Words, Longest bool

	NFlag uint
	Files []string
}

func (Options) GetBool

func (wo Options) GetBool(flag string) bool

type Results

type Results struct {
	Bytes, Characters, Newlines, Words, Longest uint

	Filename string
}

Results are the totals for output

func WordCount

func WordCount(opts Options, in io.Reader) (Results, error)

func (Results) GetMax

func (r Results) GetMax(options Options) (max uint)

GetMax number (that isn't line) from this resultset for use in max line length parameter

type ResultsSet

type ResultsSet struct {
	MaxNumber uint

	Results []Results
}

func (ResultsSet) Printf

func (rs ResultsSet) Printf(options Options) string

Printf prints all results based on format options

func (ResultsSet) String

func (rs ResultsSet) String() string

Default layout

Jump to

Keyboard shortcuts

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