stream

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 3 modules, 10 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

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownScheme is returned when an unknown scheme is encountered in a URL.
	ErrUnknownScheme = errors.New("unknown scheme")

	// ErrInvalidSource is returned when an invalid source is encountered.
	ErrInvalidSource = errors.New("invalid source")
)

Functions

func Open

func Open(uri string) (io.ReadCloser, error)

Open opens a resource identified by the given URI. It supports different schemes by utilizing registered open functions. If the URI has no scheme, it is treated as a file path.

func ReadSource added in v1.16.3

func ReadSource(src any) ([]byte, error)

ReadSource converts src to a []byte if possible; otherwise it returns an error. Supported types for src are:

  • string (as content, NOT as filename)
  • []byte (as content)
  • *bytes.Buffer (as content)
  • io.Reader (as content)

func ReadSourceFromURI added in v1.16.3

func ReadSourceFromURI(uri string, src any) ([]byte, error)

ReadSourceFromURI reads the source from the given URI. If src != nil, it reads from src; otherwise, it opens the URI and reads from it.

func ReadSourceLocal added in v1.16.3

func ReadSourceLocal(filename string, src any) ([]byte, error)

If src != nil, ReadSourceLocal converts src to a []byte if possible; otherwise it returns an error. If src == nil, ReadSourceLocal returns the result of reading the file specified by filename.

func Register

func Register(scheme string, open OpenFunc)

Register registers a scheme with an open function.

Types

type OpenFunc

type OpenFunc = func(url string) (io.ReadCloser, error)

OpenFunc defines the function type for opening a resource by URL.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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