Source file src/cmd/go/internal/imports/doc.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package imports scans Go source files for their import
     6  // declarations, evaluating build constraints, without type-checking
     7  // or otherwise loading packages. The module loader uses it to discover
     8  // the import graph, and the package loader and module index use its
     9  // evaluation of build constraints.
    10  //
    11  // [ScanDir] and [ScanFiles] return the imports and test imports of
    12  // the files of a directory or list that match a set of build tags.
    13  // [ReadImports] and [ReadComments] read only the prefix of a file
    14  // that holds its imports or its leading comments.
    15  //
    16  // [ShouldBuild], [MatchFile], and [Eval] evaluate build constraints
    17  // (//go:build lines, and file name suffixes such as _linux.go)
    18  // against a set of tags. [Tags] returns the tags of the target
    19  // platform; [AnyTags] returns a set that satisfies nearly every
    20  // constraint, for commands such as go mod tidy and go mod vendor that
    21  // must consider all platforms.
    22  package imports
    23  

View as plain text