imports

Imports

Imports #

"bytes"
"cmd/go/internal/cfg"
"errors"
"fmt"
"go/build/constraint"
"internal/syslist"
"strings"
"unicode"
"bufio"
"bytes"
"errors"
"io"
"unicode/utf8"
"fmt"
"io/fs"
"path/filepath"
"sort"
"strconv"
"strings"
"cmd/go/internal/fsys"
"cmd/go/internal/cfg"
"sync"

Constants & Variables

ErrNoGo var #

var ErrNoGo = *ast.CallExpr

anyTagsOnce var #

var anyTagsOnce = *ast.CallExpr

bPlusBuild var #

var bPlusBuild = *ast.CallExpr

bSlashSlash var #

var bSlashSlash = *ast.CallExpr

bSlashStar var #

var bSlashStar = *ast.CallExpr

bStarSlash var #

var bStarSlash = *ast.CallExpr

bom var #

var bom = []byte{...}

errMultipleGoBuild var #

var errMultipleGoBuild = *ast.CallExpr

errNUL var #

var errNUL = *ast.CallExpr

errSyntax var #

var errSyntax = *ast.CallExpr

goBuildComment var #

var goBuildComment = *ast.CallExpr

loadTagsOnce var #

var loadTagsOnce = *ast.CallExpr

Structs

importReader struct #

type importReader struct {
b *bufio.Reader
buf []byte
peek byte
err error
eof bool
nerr int
}

Functions

AnyTags function #

AnyTags returns a special set of build tags that satisfy nearly all build tag expressions. Only "ignore" and malformed build tag requirements are considered false.

func AnyTags() map[string]bool

Eval function #

Eval is like x.Eval(func(tag string) bool { return matchTag(tag, tags) }) except that it implements the special case for tags["*"] meaning all tags are both true and false at the same time.

func Eval(x constraint.Expr, tags map[string]bool, prefer bool) bool

MatchFile function #

MatchFile returns false if the name contains a $GOOS or $GOARCH suffix which does not match the current system. The recognized name formats are: name_$(GOOS).* name_$(GOARCH).* name_$(GOOS)_$(GOARCH).* name_$(GOOS)_test.* name_$(GOARCH)_test.* name_$(GOOS)_$(GOARCH)_test.* Exceptions: if GOOS=android, then files with GOOS=linux are also matched. if GOOS=illumos, then files with GOOS=solaris are also matched. if GOOS=ios, then files with GOOS=darwin 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 MatchFile(name string, tags map[string]bool) bool

ReadComments function #

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

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

ReadImports function #

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

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

ScanDir function #

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

ScanFiles function #

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

ShouldBuild function #

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.

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

Tags function #

Tags returns a set of build tags that are true for the target platform. It includes GOOS, GOARCH, the compiler, possibly "cgo", release tags like "go1.13", and user-specified build tags.

func Tags() map[string]bool

eval function #

eval is like x.Eval(func(tag string) bool { return matchTag(tag, tags) }) except that it implements the special case for tags["*"] meaning all tags are both true and false at the same time.

func eval(x constraint.Expr, tags map[string]bool, prefer bool) bool

isGoBuildComment function #

func isGoBuildComment(line []byte) bool

isIdent function #

func isIdent(c byte) bool

keys function #

func keys(m map[string]bool) []string

loadTags function #

func loadTags() map[string]bool

matchTag function #

matchTag reports whether the tag name is valid and tags[name] is true. As a special case, if tags["*"] is true and name is not empty or ignore, then matchTag will return prefer instead of the actual answer, which allows the caller to pretend in that case that most tags are both true and false.

func matchTag(name string, tags map[string]bool, prefer bool) bool

newImportReader function #

func newImportReader(b *bufio.Reader) *importReader

nextByte method #

nextByte is like peekByte but advances beyond the returned byte.

func (r *importReader) nextByte(skipSpace bool) byte

parseFileHeader function #

func parseFileHeader(content []byte) (trimmed []byte, goBuild []byte, sawBinaryOnly bool, err error)

peekByte method #

peekByte returns the next byte from the input reader but does not advance beyond it. If skipSpace is set, peekByte skips leading spaces and comments.

func (r *importReader) peekByte(skipSpace bool) byte

readByte method #

readByte reads the next byte from the input, saves it in buf, and returns it. If an error occurs, readByte records the error in r.err and returns 0.

func (r *importReader) readByte() byte

readIdent method #

readIdent reads an identifier from the input. If an identifier is not present, readIdent records a syntax error.

func (r *importReader) readIdent()

readImport method #

readImport reads an import clause - optional identifier followed by quoted string - from the input.

func (r *importReader) readImport(imports *[]string)

readKeyword method #

readKeyword reads the given keyword from the input. If the keyword is not present, readKeyword records a syntax error.

func (r *importReader) readKeyword(kw string)

readString method #

readString reads a quoted string literal from the input. If an identifier is not present, readString records a syntax error.

func (r *importReader) readString(save *[]string)

scanFiles function #

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

syntaxError method #

syntaxError records a syntax error, but only if an I/O error has not already been recorded.

func (r *importReader) syntaxError()

Generated with Arrow