input

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAll

func CloseAll(sources []Source)

CloseAll closes all sources in the slice

func MustClose

func MustClose(s *Source)

MustClose closes a source and ignores any error (for defer)

Types

type Source

type Source struct {
	Reader io.Reader
	Name   string
	Closer func() error
}

Source represents an input source (file or reader)

func Open

func Open(args []string, defaultReader io.Reader) ([]Source, error)

Open returns Sources from args (files or defaultReader if empty/"-") If args is empty, returns a single source using defaultReader with name "standard input" If an arg is "-", uses defaultReader for that position Otherwise opens the file

func OpenOne

func OpenOne(args []string, defaultReader io.Reader) (Source, error)

OpenOne returns a single Source (first arg or defaultReader if empty/"-")

func OpenOneWithDefault

func OpenOneWithDefault(args []string) (Source, error)

OpenOneWithDefault is a convenience function that opens a single source, defaulting to os.Stdin if no args provided

func OpenWithDefault

func OpenWithDefault(args []string) ([]Source, error)

OpenWithDefault is a convenience function that opens sources, defaulting to os.Stdin if no args provided

func (*Source) Close

func (s *Source) Close() error

Close closes the source if it has a closer function

Jump to

Keyboard shortcuts

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