github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/modload/import.go (about)

     1  // Copyright 2018 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 modload
     6  
     7  import (
     8  	"golang.org/x/mod/module"
     9  )
    10  
    11  type ImportMissingError struct {
    12  	Path     string
    13  	Module   module.Version
    14  	QueryErr error
    15  
    16  	ImportingMainModule module.Version
    17  
    18  	// isStd indicates whether we would expect to find the package in the standard
    19  	// library. This is normally true for all dotless import paths, but replace
    20  	// directives can cause us to treat the replaced paths as also being in
    21  	// modules.
    22  	isStd bool
    23  
    24  	// importerGoVersion is the version the module containing the import error
    25  	// specified. It is only set when isStd is true.
    26  	importerGoVersion string
    27  
    28  	// replaced the highest replaced version of the module where the replacement
    29  	// contains the package. replaced is only set if the replacement is unused.
    30  	replaced module.Version
    31  
    32  	// newMissingVersion is set to a newer version of Module if one is present
    33  	// in the build list. When set, we can't automatically upgrade.
    34  	newMissingVersion string
    35  }
    36  
    37  func (e *ImportMissingError) Error() string
    38  
    39  func (e *ImportMissingError) Unwrap() error
    40  
    41  func (e *ImportMissingError) ImportPath() string
    42  
    43  // An AmbiguousImportError indicates an import of a package found in multiple
    44  // modules in the build list, or found in both the main module and its vendor
    45  // directory.
    46  type AmbiguousImportError struct {
    47  	importPath string
    48  	Dirs       []string
    49  	Modules    []module.Version
    50  }
    51  
    52  func (e *AmbiguousImportError) ImportPath() string
    53  
    54  func (e *AmbiguousImportError) Error() string
    55  
    56  // A DirectImportFromImplicitDependencyError indicates a package directly
    57  // imported by a package or test in the main module that is satisfied by a
    58  // dependency that is not explicit in the main module's go.mod file.
    59  type DirectImportFromImplicitDependencyError struct {
    60  	ImporterPath string
    61  	ImportedPath string
    62  	Module       module.Version
    63  }
    64  
    65  func (e *DirectImportFromImplicitDependencyError) Error() string
    66  
    67  func (e *DirectImportFromImplicitDependencyError) ImportPath() string
    68  
    69  // ImportMissingSumError is reported in readonly mode when we need to check
    70  // if a module contains a package, but we don't have a sum for its .zip file.
    71  // We might need sums for multiple modules to verify the package is unique.
    72  //
    73  // TODO(#43653): consolidate multiple errors of this type into a single error
    74  // that suggests a 'go get' command for root packages that transitively import
    75  // packages from modules with missing sums. load.CheckPackageErrors would be
    76  // a good place to consolidate errors, but we'll need to attach the import
    77  // stack here.
    78  type ImportMissingSumError struct {
    79  	importPath                string
    80  	found                     bool
    81  	mods                      []module.Version
    82  	importer, importerVersion string
    83  	importerIsTest            bool
    84  }
    85  
    86  func (e *ImportMissingSumError) Error() string
    87  
    88  func (e *ImportMissingSumError) ImportPath() string