pkgindex

package
v0.0.0-...-8fe0d23 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pkgindex provides functions to index and query a local system's available go packages, allowing for quicker retrieval than traversing the file system. Suitable for use in development tools

This package has support for indexing normal go workspaces, but also provides a "gb" mode that is compatible with projects based upon the gb build tool.

This package contains a set of structures that represent various types of indexes. Notably there is the GBIndex struct and the GoPathIndex struct which wrap the other index types to provide an index over a gb project or the local system's GOPATH, respectively.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompoundIndex

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

CompoundIndex searches each of its child indexes, merging the results

func (*CompoundIndex) Add

func (idx *CompoundIndex) Add(cidx Index)

Add registers a child index, adding it to the set of indexes that will be queried when performing operations on this compound index.

func (*CompoundIndex) Index

func (idx *CompoundIndex) Index() error

Index calls through to all child indexes

func (*CompoundIndex) RefreshIfNeeded

func (idx *CompoundIndex) RefreshIfNeeded() error

RefreshIfNeeded calls through to all child indexes.

func (*CompoundIndex) Search

func (idx *CompoundIndex) Search(query string) (results []string, err error)

Search returns any packages that match the query in all child indexes.

type Index

type Index interface {
	Searchable

	Index() error
	RefreshIfNeeded() error
}

Index is the common interface to the various index structs

type ManualIndex

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

ManualIndex represents an index of manually added packages. Calling "Add"

func (*ManualIndex) Add

func (idx *ManualIndex) Add(packages ...string) error

Add appends the provided packages onto the index and triggers a re-index.

func (*ManualIndex) Index

func (idx *ManualIndex) Index() error

Index builds a new suffixarray for the package names previously registered with this instance.

func (*ManualIndex) RefreshIfNeeded

func (idx *ManualIndex) RefreshIfNeeded() error

RefreshIfNeeded is a no-op for ManualIndex instances. They are always up to date.

func (*ManualIndex) Search

func (idx *ManualIndex) Search(query string) (results []string, err error)

Search returns any packages that match the query. See documentation for the Searchable interface for details.

type Searchable

type Searchable interface {
	Search(string) ([]string, error)
}

Searchable types can filter their contained packages by the provided search string. Any package that matches the search string (described below) should get returned.

Matching is similar to that of a fuzzy-find in text editor: an entry matches the search string if each letter in the search is present in the entry in the relative order specified by the string. For example:

"aa" matches any package that has two a's in the import path
"ab" matches any package that has a "b" in its import path that follows any
     "a" in its import path
"abc" matches any package that has an "a" that precedes a "b", which in turn
     preceds an "c"

These matches are performed using regular expressions derived from the search string. The examples above would compile into the following regular expressions respectively:

^.*a.*a.*$
^.*a.*b.*$
^.*a.*b.*c.*$

type StdLibIndex

type StdLibIndex struct {
	Goroot string
	// contains filtered or unexported fields
}

StdLibIndex indexes the golang stdlib packages

func (*StdLibIndex) Index

func (idx *StdLibIndex) Index() error

Index indexes all packages as returned by "go list std"

func (*StdLibIndex) RefreshIfNeeded

func (idx *StdLibIndex) RefreshIfNeeded() error

RefreshIfNeeded TODO

func (*StdLibIndex) Search

func (idx *StdLibIndex) Search(query string) (results []string, err error)

Search returns any packages that match the query in the go standard library.

type WorkspaceIndex

type WorkspaceIndex struct {
	Dir string
	// contains filtered or unexported fields
}

WorkspaceIndex represents an index over a single go workspace, i.e. a directory with a `src` child directory that contains go source files arranged into packages. This workspace would normally be an element of the curreny process's go path or the root of a gb project

func (*WorkspaceIndex) Index

func (idx *WorkspaceIndex) Index() error

Index indexes every package in underneath the `src` directory of Dir

func (*WorkspaceIndex) RefreshIfNeeded

func (idx *WorkspaceIndex) RefreshIfNeeded() error

Jump to

Keyboard shortcuts

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