go-internal: github.com/rogpeppe/go-internal/imports Index | Files

package imports

import "github.com/rogpeppe/go-internal/imports"


Package Files

build.go read.go scan.go


var ErrNoGo = fmt.Errorf("no Go source files")
var KnownArch = make(map[string]bool)
var KnownOS = make(map[string]bool)

func MatchFile Uses

func MatchFile(name string, tags map[string]bool) bool

MatchFile returns false if the name contains a $GOOS or $GOARCH suffix which does not match the current system. The recognized name formats are:


An exception: if GOOS=android, then files with GOOS=linux are also matched.

If tags["*"] is true, then MatchFile will consider all possible GOOS and GOARCH to be available and will consequently always return true.

func ReadComments Uses

func ReadComments(f io.Reader) ([]byte, error)

ReadComments is like ioutil.ReadAll, except that it only reads the leading block of comments in the file.

func ReadImports Uses

func ReadImports(f io.Reader, reportSyntaxError bool, imports *[]string) ([]byte, error)

ReadImports is like ioutil.ReadAll, except that it expects a Go file as input and stops reading the input once the imports have completed.

func ScanDir Uses

func ScanDir(dir string, tags map[string]bool) ([]string, []string, error)

func ScanFiles Uses

func ScanFiles(files []string, tags map[string]bool) ([]string, []string, error)

func ShouldBuild Uses

func ShouldBuild(content []byte, tags map[string]bool) bool

ShouldBuild reports whether it is okay to use this file, The rule is that in the file's leading run of // comments and blank lines, which must be followed by a blank line (to avoid including a Go package clause doc comment), lines beginning with '// +build' are taken as build directives.

The file is accepted only if each such line lists something matching the file. For example:

// +build windows linux

marks the file as applicable only on Windows and Linux.

If tags["*"] is true, then ShouldBuild will consider every build tag except "ignore" to be both true and false for the purpose of satisfying build tags, in order to estimate (conservatively) whether a file could ever possibly be used in any build.

Package imports imports 13 packages (graph) and is imported by 9 packages. Updated 2018-10-05. Refresh now. Tools for package owners.