get

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: MIT, BSD-3-Clause Imports: 35 Imported by: 3

README

getter

The getter package is partial fork of:

At 549cb18a9131221755694c0ccc610ae9a406129d (Go 1.10). Getter adds modifications in order to pull using the go-git Git client into a virtual filesystem. Additionally, various features that are irrelevant to GopherJS compiles have been dropped (e.g. cgo, command line flags etc.)

Documentation

Overview

Package str provides string manipulation utilities.

Index

Constants

This section is empty.

Variables

View Source
var OutOfSpace = errors.New("out of space")

Functions

func ExpandScanner

func ExpandScanner(err error) error

ExpandScanner expands a scanner.List error into all the errors in the list. The default Error method only shows the first error and does not shorten paths.

func FindVendor

func FindVendor(path string) (index int, ok bool)

FindVendor looks for the last non-terminating "vendor" path element in the given import path. If there isn't one, FindVendor returns ok=false. Otherwise, FindVendor returns ok=true and the index of the "vendor".

Note that terminating "vendor" elements don't count: "x/vendor" is its own package, not the vendored copy of an import "" (the empty import path). This will allow people to have packages or commands named vendor. This may help reduce breakage, or it may just be confusing. We'll see.

func FoldDup

func FoldDup(list []string) (string, string)

FoldDup reports a pair of strings from the list that are equal according to strings.EqualFold. It returns "", "" if there are no such strings.

func Get

func Get(ctx context.Context, url string) ([]byte, error)

Get returns the data from an HTTP GET request for the given URL.

func GetMaybeInsecure

func GetMaybeInsecure(ctx context.Context, importPath string, insecure bool) (urlStr string, body io.ReadCloser, err error)

GetMaybeInsecure returns the body of either the importPath's https resource or, if unavailable and permitted by the security mode, the http resource.

func HasFilePathPrefix

func HasFilePathPrefix(s, prefix string) bool

HasFilePathPrefix reports whether the filesystem path s begins with the elements in prefix.

func NewWriteLimitedFilesystem

func NewWriteLimitedFilesystem(fs billy.Filesystem, max uint64) billy.Filesystem

func SafeArg

func SafeArg(name string) bool

SafeArg reports whether arg is a "safe" command-line argument, meaning that when it appears in a command-line, it probably doesn't have some special meaning other than its own name. Obviously args beginning with - are not safe (they look like flags). Less obviously, args beginning with @ are not safe (they look like GNU binutils flagfile specifiers, sometimes called "response files"). To be conservative, we reject almost any arg beginning with non-alphanumeric ASCII. We accept leading . _ and / as likely in file system paths. There is a copy of this function in cmd/compile/internal/gc/noder.go.

func StringList

func StringList(args ...interface{}) []string

StringList flattens its arguments into a single []string. Each argument in args must have type string or []string.

func ToFold

func ToFold(s string) string

ToFold returns a string with the property that

strings.EqualFold(s, t) iff ToFold(s) == ToFold(t)

This lets us test a large set of strings for fold-equivalent duplicates without making a quadratic number of calls to EqualFold. Note that strings.ToUpper and strings.ToLower do not have the desired property in some corner cases.

func WithCancel

func WithCancel(ctx context.Context, f func()) bool

WithCancel executes the provided function, but returns early with true if the context cancellation signal was recieved.

Types

type Getter

type Getter struct {
	Callback func(path string, files map[string]string, standard bool) error
	// contains filtered or unexported fields
}

func New

func New(sess *session.Session, send func(services.Message), cache *cache.Request) *Getter

func (*Getter) ClearPackageCachePartial

func (g *Getter) ClearPackageCachePartial(args []string)

func (*Getter) Get

func (g *Getter) Get(ctx context.Context, path string, update bool, insecure, single bool) error

func (*Getter) LinkerDeps

func (g *Getter) LinkerDeps(p *Package) []string

LinkerDeps returns the list of linker-induced dependencies for main package p.

func (*Getter) LoadImport

func (g *Getter) LoadImport(ctx context.Context, path, srcDir string, parent *Package, stk *ImportStack, useVendor bool) *Package

LoadImport scans the directory named by path, which must be an import path, but possibly a local import path (an absolute file system path or one beginning with ./ or ../). A local relative path is interpreted relative to srcDir. It returns a *Package describing the package found in that directory.

func (*Getter) VendoredImportPath

func (g *Getter) VendoredImportPath(parent *Package, path string) (found string)

VendoredImportPath returns the expansion of path when it appears in parent. If parent is x/y/z, then path might expand to x/y/z/vendor/path, x/y/vendor/path, x/vendor/path, vendor/path, or else stay path if none of those exist. VendoredImportPath returns the expanded path or, if no expansion is found, the original.

type HTTPError

type HTTPError struct {
	StatusCode int
	// contains filtered or unexported fields
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type ImportMismatchError

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

A ImportMismatchError is returned where metaImport/s are present but none match our import path.

func (ImportMismatchError) Error

func (m ImportMismatchError) Error() string

type ImportStack

type ImportStack []string

An ImportStack is a stack of import paths.

func (*ImportStack) Copy

func (s *ImportStack) Copy() []string

func (*ImportStack) Pop

func (s *ImportStack) Pop()

func (*ImportStack) Push

func (s *ImportStack) Push(p string)

type NoGoError

type NoGoError struct {
	Package *Package
}

func (*NoGoError) Error

func (e *NoGoError) Error() string

type Package

type Package struct {
	PackagePublic                 // visible in 'go list'
	Internal      PackageInternal // for use inside go command only
}

A Package describes a single package found in a directory.

func (*Package) AllFiles

func (p *Package) AllFiles() []string

AllFiles returns the names of all the files considered for the package. This is used for sanity and security checks, so we include all files, even IgnoredGoFiles, because some subcommands consider them. The go/build package filtered others out (like foo_wrongGOARCH.s) and that's OK.

type PackageError

type PackageError struct {
	ImportStack   []string // shortest path from package named on command line to this one
	Pos           string   // position of error
	Err           string   // the error itself
	IsImportCycle bool     `json:"-"` // the error is an import cycle
	Hard          bool     `json:"-"` // whether the error is soft or hard; soft errors are ignored in some places
}

A PackageError describes an error loading information about a package.

func (*PackageError) Error

func (p *PackageError) Error() string

type PackageInternal

type PackageInternal struct {
	// Unexported fields are not part of the public API.
	Build   *build.Package
	Imports []*Package // this package's direct imports
	Local   bool       // imported via local path (./ or ../)

	Asmflags   []string // -asmflags for this package
	Gcflags    []string // -gcflags for this package
	Ldflags    []string // -ldflags for this package
	Gccgoflags []string // -gccgoflags for this package
}

type PackagePublic

type PackagePublic struct {

	// Note: These fields are part of the go command's public API.
	// See list.go. It is okay to add fields, but not to change or
	// remove existing ones. Keep in sync with list.go
	Dir           string `json:",omitempty"` // directory containing package sources
	ImportPath    string `json:",omitempty"` // import path of package in dir
	ImportComment string `json:",omitempty"` // path in import comment on package statement
	Name          string `json:",omitempty"` // package name
	Doc           string `json:",omitempty"` // package documentation string
	Goroot        bool   `json:",omitempty"` // is this package found in the Go root?
	Standard      bool   `json:",omitempty"` // is this package part of the standard Go library?
	Root          string `json:",omitempty"` // Go root or Go path dir containing this package

	// Source files
	// If you add to this list you MUST add to p.AllFiles (below) too.
	// Otherwise file name security lists will not apply to any new additions.
	GoFiles        []string `json:",omitempty"` // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
	IgnoredGoFiles []string `json:",omitempty"` // .go sources ignored due to build constraints

	// Dependency information
	Imports []string `json:",omitempty"` // import paths used by this package
	Deps    []string `json:",omitempty"` // all (recursively) imported dependencies

	// Error information
	Incomplete bool            `json:",omitempty"` // was there an error loading this package or dependencies?
	Error      *PackageError   `json:",omitempty"` // error loading this package (not dependencies)
	DepsErrors []*PackageError `json:",omitempty"` // errors loading dependencies
	// contains filtered or unexported fields
}

type WriteLimitedFile

type WriteLimitedFile struct {
	billy.File
	// contains filtered or unexported fields
}

func (*WriteLimitedFile) Write

func (w *WriteLimitedFile) Write(p []byte) (n int, err error)

type WriteLimitedFilesystem

type WriteLimitedFilesystem struct {
	billy.Filesystem
	// contains filtered or unexported fields
}

func (*WriteLimitedFilesystem) Chroot

func (w *WriteLimitedFilesystem) Chroot(path string) (billy.Filesystem, error)

func (*WriteLimitedFilesystem) Create

func (w *WriteLimitedFilesystem) Create(filename string) (billy.File, error)

func (*WriteLimitedFilesystem) Open

func (w *WriteLimitedFilesystem) Open(filename string) (billy.File, error)

func (*WriteLimitedFilesystem) OpenFile

func (w *WriteLimitedFilesystem) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)

func (*WriteLimitedFilesystem) TempFile

func (w *WriteLimitedFilesystem) TempFile(dir, prefix string) (billy.File, error)

Jump to

Keyboard shortcuts

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