pkg

package module
v0.0.0-...-460bd45 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMultiplePackage

func IsMultiplePackage(err error) bool

Returns, if the error err is MultiplePackageError error.

func IsNoBuildableGo

func IsNoBuildableGo(err error) bool

Returns, if the error err is NoBuildableGoError error.

func IsNoGo

func IsNoGo(err error) bool

Returns, if the error err is NoGoError error.

Types

type Context

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

A Context provides safe-concurrent access to a build.Context, that optionally checks for changes to Go specific environment variables (GOROOT, GOPATH).

func NewContext

func NewContext(ctxt *build.Context, updateInterval time.Duration) *Context

NewContext, returns a new Context for build.Context ctxt with an update interval of updateInterval. If updateInterval is less than or equal to zero the returned Context will not check the environment for changes to GOROOT and GOPATH.

If ctxt is nil, build.Default and the current GOROOT and GOPATH are used.

func (*Context) Context

func (c *Context) Context() *build.Context

Context returns a pointer the the current build.Context. The returned *build.Context should *not* be modified by the reciever.

func (*Context) GOPATH

func (c *Context) GOPATH() string

GOPATH returns the GOPATH of Context.

func (*Context) GOROOT

func (c *Context) GOROOT() string

GOROOT returns the GOROOT of Context.

func (*Context) MatchFile

func (c *Context) MatchFile(dir, name string) bool

MatchFile reports whether the file with the given name in the given directory matches the context and would be included in a Package created by ImportDir of that directory.

MatchFile considers the name of the file and may use ctxt.OpenFile to read some or all of the file's content.

See: go/build/build.go Context.MatchFile for more information.

func (*Context) PkgTargetRoot

func (c *Context) PkgTargetRoot(path string) (pkgRoot string, pkgA string, err error)

PkgTargetRoot, returns the package directory and package .a file for the Go package named by the import path and the current context.

See: go/build/build.go Import() for more information.

func (*Context) SetGoPath

func (c *Context) SetGoPath(s string)

SetGoPath sets the Context GOPATH.

func (*Context) SetGoRoot

func (c *Context) SetGoRoot(s string)

SetGoRoot sets the Context GOROOT.

func (*Context) SrcDirs

func (c *Context) SrcDirs() []string

SrcDirs returns a list of package source root directories. It draws from the current Go root and Go path but omits directories that do not exist.

Results are cached for efficieny and only updated when GOROOT or GOPATH change.

func (*Context) Update

func (c *Context) Update()

Update, updates or initializes a Context that is outdated or has a nil build.Context or SrcDirs.

type Corpus

type Corpus struct {
	MaxDepth      int
	LogEvents     bool
	IndexGoCode   bool
	IndexThrottle float64
	IndexInterval time.Duration
	// contains filtered or unexported fields
}

func NewCorpus

func NewCorpus() *Corpus

TODO: Do we care about missing GOROOT and GOPATH env vars?

func (*Corpus) DirList

func (c *Corpus) DirList() map[string]*DirList

func (*Corpus) Dirs

func (c *Corpus) Dirs() map[string]*Directory

WARN

func (*Corpus) Idents

func (c *Corpus) Idents() []Ident

WARN

func (*Corpus) Init

func (c *Corpus) Init() error

func (*Corpus) Packages

func (c *Corpus) Packages() map[string]map[string]*Package

WARN

func (*Corpus) Stop

func (c *Corpus) Stop()

func (*Corpus) Update

func (c *Corpus) Update()

WARN

type DirEntry

type DirEntry struct {
	Depth    int    // >= 0
	Height   int    // = DirList.MaxHeight - Depth, > 0
	Path     string // directory path; includes Name, relative to DirList root
	Name     string // directory name
	PkgName  string // package name, or "" if none
	HasPkg   bool   // true if the directory contains at least one package
	Internal bool   // true if the package is an "internal" package
}

type DirList

type DirList struct {
	MaxHeight int // directory tree height, > 0
	List      []DirEntry
}

type Directory

type Directory struct {
	Path     string                // directory path
	Name     string                // directory name
	PkgName  string                // Go pkg name
	HasPkg   bool                  // has Go pkg
	Internal bool                  // Internal Go pkg
	Info     os.FileInfo           // FileInfo
	Dirs     map[string]*Directory // Sub-directories
	Depth    int                   // Distance from root
}

type Event

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

func (Event) Callback

func (e Event) Callback(c *Corpus) error

func (Event) Event

func (e Event) Event() EventType

func (Event) String

func (e Event) String() string

type EventType

type EventType int
const (
	CreateEvent EventType = iota
	UpdateEvent
	DeleteEvent
)

func (EventType) String

func (e EventType) String() string

type Eventer

type Eventer interface {
	Event() EventType
	String() string
	Callback(c *Corpus) error
}

type File

type File struct {
	Name string      // file name
	Path string      // absolute file path
	Info os.FileInfo // file info, used for updating
}

func NewFile

func NewFile(path string, info bool) (File, error)

TODO: Remove if unused.

func (*File) IsValid

func (f *File) IsValid() bool

func (File) String

func (f File) String() string

type FileMap

type FileMap map[string]File

A FileMap is a map of related files.

func (FileMap) FileNames

func (m FileMap) FileNames() []string

Files, returns the file names in the FileMap as a slice.

func (FileMap) FilePaths

func (m FileMap) FilePaths() []string

Files, returns the file paths in the FileMap as a slice.

func (FileMap) Files

func (m FileMap) Files() []File

Files, returns the files in the FileMap as a slice.

type GoFileType

type GoFileType int

A GoFileType describes a Go file in a package directory.

const (
	IgnoredGoFile GoFileType = 1 + iota // .go source files (excluding TestGoFiles and IgnoredGoFiles)
	TestGoFile                          // .go source files ignored for this build
	GoFile                              // _test.go files in package (build tags are not checked)
)

func (GoFileType) IsValid

func (t GoFileType) IsValid() bool

func (GoFileType) String

func (t GoFileType) String() string

type Ident

type Ident struct {
	Name    string  // Type, func or type.method name
	Package string  // Package name "http"
	Path    string  // Package path "net/http"
	File    string  // File where declared "$GOROOT/src/net/http/server.go"
	Info    TypInfo // Type and position info
}

func (*Ident) IsExported

func (i *Ident) IsExported() bool

IsExported reports whether the Ident is an exported Go symbol.

type Index

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

func (*Index) ExportedPackages

func (x *Index) ExportedPackages() []string

WARN WARN

func (*Index) Idents

func (x *Index) Idents() []Ident

WARN

type IndexEvent

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

func (IndexEvent) Callback

func (e IndexEvent) Callback(c *Corpus) error

func (IndexEvent) Event

func (e IndexEvent) Event() EventType

func (IndexEvent) String

func (e IndexEvent) String() string

type MultiplePackageError

type MultiplePackageError struct {
	Dir      string   // directory containing files
	Packages []string // package names found
	Files    []string // corresponding files: Files[i] declares package Packages[i]
}

MultiplePackageError describes a directory containing multiple buildable Go source files for multiple packages.

func (*MultiplePackageError) Error

func (e *MultiplePackageError) Error() string

type NoBuildableGoError

type NoBuildableGoError struct {
	Dir string
}

NoGoError is the error used by Import to describe a directory containing no buildable Go source files. (It may still contain test files, files hidden by build tags, and so on.)

func (*NoBuildableGoError) Error

func (e *NoBuildableGoError) Error() string

type NoGoError

type NoGoError struct {
	Dir string
}

NoGoError is the error used by Import to describe a directory containing no Go source files.

func (*NoGoError) Error

func (e *NoGoError) Error() string

type Package

type Package struct {
	Dir        string      // Directory path "$GOROOT/src/net/http"
	Name       string      // Package name "http"
	ImportPath string      // Import path of package "net/http"
	Root       string      // Root of Go tree where this package lives
	SrcRoot    string      // package source root directory
	Goroot     bool        // Package found in Go root
	Installed  bool        // True if the package or command is installed
	Info       os.FileInfo // File info as of last update
	// contains filtered or unexported fields
}

A Package describes a Go package or command.

func (*Package) Error

func (p *Package) Error() error

Error, returns either NoGoError or MultiplePackageError.

func (*Package) FileNames

func (p *Package) FileNames(typ GoFileType) []string

FileNames, returns the names of files that match GoFileType typ. If GoFileType typ is less than zero all files are matched.

func (*Package) FilePaths

func (p *Package) FilePaths(typ GoFileType) []string

FilePaths, returns the paths of files that match GoFileType typ. If GoFileType typ is less than zero all files are matched.

func (*Package) Files

func (p *Package) Files(typ GoFileType) []File

File, returns the files that match GoFileType typ. If GoFileType typ is less than zero all files are matched.

func (*Package) GoFiles

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

GoFiles, returns a slice of buildable Go source files in the package.

func (*Package) IsCommand

func (p *Package) IsCommand() bool

IsCommand reports whether the package is considered a command to be installed (not just a library). Packages named "main" are treated as commands.

func (*Package) IsValid

func (p *Package) IsValid() bool

func (*Package) LookupFile

func (p *Package) LookupFile(name string) (File, bool)

type PackageIndex

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

func (*PackageIndex) ImportDir

func (x *PackageIndex) ImportDir(dir string) (*Package, error)

TODO: Remove if unused.

func (*PackageIndex) InvalidateContext

func (x *PackageIndex) InvalidateContext(matchFiles bool)

func (*PackageIndex) UpdatePackage

func (x *PackageIndex) UpdatePackage(p *Package) (*Package, error)

type TypInfo

type TypInfo uint64

A TypeInfo value describes a particular identifier spot in a given file. It encodes three values: the TypeKind, and the file line and offset.

The following encoding is used:

bits    64     32    4    1
value     [offset|line|kind]

TODO (CEV): Add line offset.

func (TypInfo) Kind

func (t TypInfo) Kind() TypKind

func (TypInfo) Line

func (t TypInfo) Line() int

func (TypInfo) MarshalJSON

func (t TypInfo) MarshalJSON() ([]byte, error)

func (TypInfo) Offset

func (t TypInfo) Offset() int

func (TypInfo) String

func (t TypInfo) String() string

func (*TypInfo) UnmarshalJSON

func (t *TypInfo) UnmarshalJSON(b []byte) error

type TypKind

type TypKind uint32

TypKind describes the kind of a Go identifier.

const (
	InvalidDecl TypKind = iota
	ConstDecl
	VarDecl
	TypeDecl
	FuncDecl
	MethodDecl
	InterfaceDecl
)

func (TypKind) IsValid

func (t TypKind) IsValid() bool

IsValid, returns if t is a valid TypKind.

func (TypKind) MarshalJSON

func (t TypKind) MarshalJSON() ([]byte, error)

func (TypKind) Name

func (t TypKind) Name() string

Name, returns the name (string representation) of t.

func (TypKind) String

func (t TypKind) String() string

String, returns the string representation of t.

func (*TypKind) UnmarshalJSON

func (t *TypKind) UnmarshalJSON(b []byte) (err error)

Directories

Path Synopsis
Package fs provides file-system utilities and an implementation of os.FileInfo that implements the GobEncode, GobDecode, MarshalJSON and UnmarshalJSON interfaces.
Package fs provides file-system utilities and an implementation of os.FileInfo that implements the GobEncode, GobDecode, MarshalJSON and UnmarshalJSON interfaces.

Jump to

Keyboard shortcuts

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