get

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

README

go-get

A repository fetcher, forked from golang/go

Build Status PkgGoDev

Why?

When in doubt, simply port Go's source code, documentation, and tests.

Tilt needs a system for importing extensions.

We love the Go package-import system.

We decided to copy it!

But when we looked at how Go's go get was implemented, we saw that it supports a lot of different repositories.

This package contains a fork of that package, to make it easier to re-use.

How?

package get_test

import (
	"fmt"
	"os/user"
	"path/filepath"
	"testing"

	"github.com/tilt-dev/go-get"
)

func ExampleGet(t *testing.T) {
	usr, _ := user.Current()
	downloader := get.NewDownloader(filepath.Join(usr.HomeDir, ".cache", "go-get"))
	path, err := downloader.Download("github.com/tilt-dev/tilt-extensions/hello_world")
	if err != nil {
		t.Fatal(err)
	}

	fmt.Printf("Downloaded to %s\n", path)
}

License

Licensed under 3-clause BSD

Originally Copyright (c) 2009 The Go Authors. All rights reserved.

Modified by Windmill Engineering, Inc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

type Downloader struct {
	Stderr io.Writer
	// contains filtered or unexported fields
}

Downloader fetches repositories under the given source tree. Not thread-safe.

func NewDownloader

func NewDownloader(srcRoot string) *Downloader

func (*Downloader) DestinationPath

func (d *Downloader) DestinationPath(pkg string) string

Determines where the repository will be downloaded before we download it.

func (*Downloader) Download

func (d *Downloader) Download(pkg string) (string, error)

Download runs the create or download command to make the first copy of or update a copy of the given package.

func (*Downloader) HeadRef

func (d *Downloader) HeadRef(pkg string) (string, error)

Determines the hash of the currently checked out head.

Returns the empty string if the current VCS does not support HEAD references.

func (*Downloader) RefSync

func (d *Downloader) RefSync(pkg, tag string) error

Update the checked out repo to the given ref. Assumes the repo has already been downloaded.

type ImportPathError

type ImportPathError interface {
	error
	ImportPath() string
}

ImportPathError is a type of error that prevents a package from being loaded for a given import path. When such a package is loaded, a *Package is returned with Err wrapping an ImportPathError: the error is attached to the imported package, not the importing package.

The string returned by ImportPath must appear in the string returned by Error. Errors that wrap ImportPathError (such as PackageError) may omit the import path.

func ImportErrorf

func ImportErrorf(path, format string, args ...interface{}) ImportPathError

Directories

Path Synopsis
internal
auth
Package auth provides access to user-provided authentication credentials.
Package auth provides access to user-provided authentication credentials.
web
Package web defines minimal helper routines for accessing HTTP/HTTPS resources without requiring external dependenicies on the net package.
Package web defines minimal helper routines for accessing HTTP/HTTPS resources without requiring external dependenicies on the net package.

Jump to

Keyboard shortcuts

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