remote

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() string

func IsRemote

func IsRemote(goGetterSrc string) bool

Types

type Getter

type Getter interface {
	Get(wd, src, dst string) error
}

type GoGetter

type GoGetter struct {
	Logger *zap.SugaredLogger
}

func (*GoGetter) Get

func (g *GoGetter) Get(wd, src, dst string) error

type InvalidURLError

type InvalidURLError struct {
	// contains filtered or unexported fields
}

func (InvalidURLError) Error

func (e InvalidURLError) Error() string

type Remote

type Remote struct {
	Logger *zap.SugaredLogger

	// Home is the directory in which remote downloads files. If empty, user cache directory is used
	Home string

	// Getter is the underlying implementation of getter used for fetching remote files
	Getter Getter

	// ReadFile is the implementation of the file reader that reads a local file from the specified path.
	// Inject any implementation of your choice, like an im-memory impl for testing, ioutil.ReadFile for the real-world use.
	ReadFile   func(string) ([]byte, error)
	DirExists  func(string) bool
	FileExists func(string) bool
}

func NewRemote

func NewRemote(logger *zap.SugaredLogger, homeDir string, readFile func(string) ([]byte, error), dirExists func(string) bool, fileExists func(string) bool) *Remote

func (*Remote) Fetch

func (r *Remote) Fetch(goGetterSrc string, cacheDirOpt ...string) (string, error)

func (*Remote) GetBytes

func (r *Remote) GetBytes(goGetterSrc string) ([]byte, error)

func (*Remote) Locate

func (r *Remote) Locate(urlOrPath string) (string, error)

Locate takes an URL to a remote file or a path to a local file. If the argument was an URL, it fetches the remote directory contained within the URL, and returns the path to the file in the fetched directory

func (*Remote) Unmarshal

func (r *Remote) Unmarshal(src string, dst interface{}) error

type Source

type Source struct {
	Getter, Scheme, User, Host, Dir, File, RawQuery string
}

func Parse

func Parse(goGetterSrc string) (*Source, error)

Jump to

Keyboard shortcuts

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