buildutil

package
v0.0.0-...-3e34946 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2014 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package buildutil provides utilities related to the go/build package in the standard library.

All I/O is done via the build.Context file system interface, which must be concurrency-safe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllPackages

func AllPackages(ctxt *build.Context) []string

AllPackages returns the import path of each Go package in any source directory of the specified build context (e.g. $GOROOT or an element of $GOPATH). Errors are ignored. The results are sorted.

The result may include import paths for directories that contain no *.go files, such as "archive" (in $GOROOT/src).

All I/O is done via the build.Context file system interface, which must be concurrency-safe.

func ContainingPackage

func ContainingPackage(ctxt *build.Context, dir, filename string) (*build.Package, error)

ContainingPackage returns the package containing filename.

If filename is not absolute, it is interpreted relative to working directory dir. All I/O is via the build context's file system interface, if any.

The '...Files []string' fields of the resulting build.Package are not populated (build.FindOnly mode).

TODO(adonovan): call this from oracle when the tree thaws.

func FileExists

func FileExists(ctxt *build.Context, path string) bool

FileExists returns true if the specified file exists, using the build context's file system interface.

func ForEachPackage

func ForEachPackage(ctxt *build.Context, found func(importPath string, err error))

ForEachPackage calls the found function with the import path of each Go package it finds in any source directory of the specified build context (e.g. $GOROOT or an element of $GOPATH).

If the package directory exists but could not be read, the second argument to the found function provides the error.

The found function and the build.Context file system interface accessors must be concurrency safe.

func IsAbsPath

func IsAbsPath(ctxt *build.Context, path string) bool

IsAbsPath behaves like filepath.IsAbs, but uses the build context's file system interface, if any.

func IsDir

func IsDir(ctxt *build.Context, path string) bool

IsDir behaves like os.Stat plus IsDir, but uses the build context's file system interface, if any.

func JoinPath

func JoinPath(ctxt *build.Context, path ...string) string

JoinPath behaves like filepath.Join, but uses the build context's file system interface, if any.

func OpenFile

func OpenFile(ctxt *build.Context, path string) (io.ReadCloser, error)

OpenFile behaves like os.Open, but uses the build context's file system interface, if any.

func ParseFile

func ParseFile(fset *token.FileSet, ctxt *build.Context, displayPath func(string) string, dir string, file string, mode parser.Mode) (*ast.File, error)

ParseFile behaves like parser.ParseFile, but uses the build context's file system interface, if any.

If file is not absolute (as defined by IsAbsPath), the (dir, file) components are joined using JoinPath; dir must be absolute.

The displayPath function, if provided, is used to transform the filename that will be attached to the ASTs.

TODO(adonovan): call this from go/loader.parseFiles when the tree thaws.

func ReadDir

func ReadDir(ctxt *build.Context, path string) ([]os.FileInfo, error)

ReadDir behaves like ioutil.ReadDir, but uses the build context's file system interface, if any.

func SplitPathList

func SplitPathList(ctxt *build.Context, s string) []string

SplitPathList behaves like filepath.SplitList, but uses the build context's file system interface, if any.

Types

This section is empty.

Jump to

Keyboard shortcuts

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