count

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package count implements the core counters used in gowc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bytes added in v0.3.0

type Bytes uint64

func (*Bytes) Write added in v0.3.0

func (b *Bytes) Write(data []byte) (int, error)

Write implements io.Writer for Bytes.

It doesn't actually write anything, but increments the byte count on every byte in data, allowing a Bytes to be used as dst in a call to io.Copy.

type Chars added in v0.3.0

type Chars uint64

func (*Chars) Write added in v0.3.0

func (c *Chars) Write(data []byte) (int, error)

Write implements io.Writer for Chars.

It doesn't actually write anything, but increments the char count on every utf8 rune in data, allowing a Chars to be used as dst in a call to io.Copy.

type Lines added in v0.3.0

type Lines uint64

func (*Lines) Write added in v0.3.0

func (l *Lines) Write(data []byte) (int, error)

Write implements io.Writer for Lines.

It doesn't actually write anything, but increments the line count on every newline in data, allowing a Lines to be used as dst in a call to io.Copy.

type Result

type Result struct {
	Err   error  `json:"-"`
	Name  string `json:"name"`
	Lines Lines  `json:"lines"`
	Bytes Bytes  `json:"bytes"`
	Words Words  `json:"words"`
	Chars Chars  `json:"chars"`
}

Result encodes the result of a counting operation on a file.

func One

func One(in io.Reader, name string) Result

One performs a counting operation on a single reader, returning the result and any error.

func (Result) Display

func (r Result) Display(w io.Writer, toJSON bool) error

Display outputs the Count as a pretty table to w.

type Results

type Results []Result

Results encodes multiple Results from different files.

func All

func All(files []string) Results

All performs counting operations on multiple files concurrently gathering up the results and returning.

func (Results) Display

func (r Results) Display(w io.Writer, toJSON bool) error

Display outputs the Results to w.

type Words added in v0.3.0

type Words uint64

func (*Words) Write added in v0.3.0

func (w *Words) Write(data []byte) (int, error)

Write implements io.Writer for Words.

It doesn't actually write anything, but increments the word count on every word in data, allowing a Words to be used as dst in a call to io.Copy.

Jump to

Keyboard shortcuts

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