files

package
v0.0.0-...-026a6ea Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

files defines a set of abstraction for 'files': an openable entities that could be read after.

This is not a file on a filesystem of your local machine, it also can include "in memory" files or even remote ones, like HTTP endpoints. If you make a GET request to HTTP endpoint, then a body is readable and you can consider it as an openable file.

Index

Constants

This section is empty.

Variables

View Source
var ErrBadHTTPClient = errors.New("incorrect http client")

ErrBadHTTPClient is returned if given HTTP client is initialized incorrectly.

Functions

This section is empty.

Types

type File

type File interface {
	// Open returns an readable entity for a file. It is important to not forget
	// to close it after the usage.
	Open(context.Context) (io.ReadCloser, error)

	// String returns a short text description for the file
	String() string
}

File is an abstraction for a entity that can be opened in some context.

func NewHTTP

func NewHTTP(client *http.Client, endpoint string) (File, error)

NewHTTP returns a file abstraction for HTTP/HTTPS endpoint. You also need to provide a valid instance of http.Client to access it.

func NewLocal

func NewLocal(path string) (File, error)

NewLocal returns an openable File for a path on a local file system.

func NewMem

func NewMem(networks []*net.IPNet) File

NewMem returns an openable file that is kept in RAM.

Jump to

Keyboard shortcuts

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