detect

package
v0.0.0-...-f90e41b Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Detect

func Detect(src string, ds []Detector) (string, error)

Detect turns a source string into another source string if it is detected to be of a known pattern.

The third parameter should be the list of detectors to use in the order to try them. If you don't want to configure this, just use the global Detectors variable.

This is safe to be called with an already valid source string: Detect will just return it.

func SourceDirSubdir

func SourceDirSubdir(src string) (string, string)

SourceDirSubdir takes a source URL and returns a tuple of the URL without the subdir and the subdir.

ex:

dom.com/path/?q=p               => dom.com/path/?q=p, ""
proto://dom.com/path//*?q=p     => proto://dom.com/path?q=p, "*"
proto://dom.com/path//path2?q=p => proto://dom.com/path?q=p, "path2"

func SubdirGlob

func SubdirGlob(dst, subDir string) (string, error)

SubdirGlob returns the actual subdir with globbing processed.

dst should be a destination directory that is already populated (the download is complete) and subDir should be the set subDir. If subDir is an empty string, this returns an empty string.

The returned path is the full absolute path.

Types

type BitBucketDetector

type BitBucketDetector struct{}

BitBucketDetector implements Detector to detect BitBucket URLs and turn them into URLs that the Git or Hg Getter can understand.

func (*BitBucketDetector) Detect

func (d *BitBucketDetector) Detect(src string) (string, bool, error)

type Detector

type Detector interface {
	// Detect will detect whether the string matches a known pattern to
	// turn it into a proper URL.
	Detect(string) (string, bool, error)
}

Detector defines the interface that an invalid URL or a URL with a blank scheme is passed through in order to determine if its shorthand for something else well-known.

type GCSDetector

type GCSDetector struct{}

GCSDetector implements Detector to detect GCS URLs and turn them into URLs that the GCSGetter can understand.

func (*GCSDetector) Detect

func (d *GCSDetector) Detect(src string) (string, bool, error)

type GitDetector

type GitDetector struct{}

GitDetector implements Detector to detect Git SSH URLs such as git@host.com:dir1/dir2 and converts them to proper URLs.

func (*GitDetector) Detect

func (d *GitDetector) Detect(src string) (string, bool, error)

type GitHubDetector

type GitHubDetector struct{}

GitHubDetector implements Detector to detect GitHub URLs and turn them into URLs that the Git Getter can understand.

func (*GitHubDetector) Detect

func (d *GitHubDetector) Detect(src string) (string, bool, error)

type S3Detector

type S3Detector struct{}

S3Detector implements Detector to detect S3 URLs and turn them into URLs that the S3 getter can understand.

func (*S3Detector) Detect

func (d *S3Detector) Detect(src string) (string, bool, error)

Jump to

Keyboard shortcuts

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