resolver

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindGoImport

func FindGoImport(reader io.Reader) (importLine string, found bool, err error)

FindGoImport searches for a `go-import` through the contents of a reader, capturing the `go-import` content's if found.

Ref: https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies

Types

type GoImport

type GoImport struct {
	ImportPrefix string
	VCS          string
	RepoRoot     string
}

GoImport is a representation of the contents that get parsed from a `go-import` meta element in an HTML page.

For instance:

<meta
	name="go-import"
	content="gopkg.in/yaml.v2 git https://gopkg.in/yaml.v2" --> what GoImport represents
>

func ParseGoImport

func ParseGoImport(content string) (res GoImport, err error)

ParseGoImport parses the value associated with the content tag of a `go-import` header meta element.

type Location

type Location struct {
	VCS string
	URL string
}

func Resolve

func Resolve(ctx context.Context, dependency string) (loc Location, err error)

Resolve retrieves a dependency's source code location from a dependency line, eventually performing an underlying HTTP request for retriving the `go-import` tag if needed.

func RetrieveLocationFromGoImport

func RetrieveLocationFromGoImport(ctx context.Context, address string) (loc Location, err error)

RetrieveLocationFromGoImport retrieves import location information by performing a request for the dependency website and searching for a `go-import` tag.

func RetrieveLocationFromKnownHostingWebsite

func RetrieveLocationFromKnownHostingWebsite(address string) (loc Location, unknownHost bool, err error)

RetrieveLocationFromKnownHostingWebsite tries to retrieve a Location for a given dependency from a known set of rules for a common set of hosting websites.

Ref: https://github.com/golang/go/blob/cf8cc7f63c7ddefb666a6e8d99a4843d3277db9f/src/cmd/go/internal/help/helpdoc.go#L152-L158

Jump to

Keyboard shortcuts

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