Documentation ¶
Index ¶
- func AddToolchain(t Toolchain)
- func AdvancedFetchFile(ctx context.Context, urls []string, localFile string) (err error)
- func DetectFastestURL(ctx context.Context, urls []string) (fastest string, err error)
- func FetchFile(ctx context.Context, url string, localFile string) (err error)
- func FetchJSON(ctx context.Context, url string, v interface{}) (err error)
- func FetchQueryHTML(ctx context.Context, url string, sel string, ...) (err error)
- func FindBestVersion(c *semver.Constraints, versions semver.Collection) (idx int, version *semver.Version, err error)
- func FindBestVersionedItem[T any](c *semver.Constraints, items []T, ...) (matched T, err error)
- func InstallArchive(ctx context.Context, opts InstallArchiveOptions) (dir string, err error)
- func TryFetch(ctx context.Context, url string) (delay time.Duration, err error)
- type InstallArchiveOptions
- type Spec
- type Toolchain
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdvancedFetchFile ¶
AdvancedFetchFile detect fastest url from candidate urls and fetch file to local path
func DetectFastestURL ¶
DetectFastestURL detects the fastest url from urls
func FetchQueryHTML ¶
func FetchQueryHTML(ctx context.Context, url string, sel string, fn func(i int, s *goquery.Selection)) (err error)
FetchQueryHTML fetches html from url, and find elements by selector, and call fn for each element
func FindBestVersion ¶
func FindBestVersion(c *semver.Constraints, versions semver.Collection) (idx int, version *semver.Version, err error)
FindBestVersion finds the best match version from a list of versions. The returned index is the index of the version in the original list. The returned version is the best match version. The returned error is nil if there is a match, otherwise it is not nil. nil value in input versions will be ignored.
func FindBestVersionedItem ¶
func FindBestVersionedItem[T any](c *semver.Constraints, items []T, fn func(v T) (version *semver.Version, err error)) (matched T, err error)
FindBestVersionedItem finds the best match version item from a list of items. If there is a match, the returned matched item is the best match item. The returned error is nil if there is a match, otherwise it is not nil. nil value and failed value in input items will be ignored.
func InstallArchive ¶
func InstallArchive(ctx context.Context, opts InstallArchiveOptions) (dir string, err error)
InstallArchive installs an archive to a directory
Types ¶
type InstallArchiveOptions ¶
type Spec ¶
type Spec struct { // Name is the name of the toolchain. Name string // VersionRaw is the original version string, without any prefixing 'v'. VersionRaw string // Version is the version requested Version *semver.Version // VersionConstraints is the version constraints with tide. VersionConstraints *semver.Constraints // OS is the target operating system. // follows go convention, see https://go.dev/doc/install/source#environment for values. OS string // Arch is the target architecture. // follows go convention, see https://go.dev/doc/install/source#environment for values. Arch string }
Spec is a toolchain spec. It is used to identify a toolchain.
func (Spec) ConvertPlatform ¶
ConvertPlatform converts the platform strings to the target platform.
func (Spec) VersionHasMinor ¶
VersionHasMinor returns whether the version has minor.
func (Spec) VersionHasPatch ¶
VersionHasPatch returns whether the version has patch.
func (Spec) VersionedName ¶
type Toolchain ¶
type Toolchain interface { // Support returns whether the toolchain supports the spec. Support(spec Spec) bool // Activate download, install and activate the toolchain Activate(ctx context.Context, spec Spec) (script string, err error) }
Toolchain is an interface abstracting a toolchain.
func FindToolchain ¶
FindToolchain finds a toolchain by spec.