"Fossies" - the Fresh Open Source Software Archive

Member "buildah-1.27.2/tests/tools/vendor/github.com/golangci/golangci-lint/pkg/golinters/goanalysis/adapters.go" (20 Sep 2022, 918 Bytes) of package /linux/misc/buildah-1.27.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "adapters.go": 1.26.4_vs_1.27.0.

    1 package goanalysis
    2 
    3 import (
    4     "go/types"
    5 
    6     "golang.org/x/tools/go/analysis"
    7     "golang.org/x/tools/go/loader" //nolint:staticcheck // it's an adapter for golang.org/x/tools/go/packages
    8 )
    9 
   10 func MakeFakeLoaderProgram(pass *analysis.Pass) *loader.Program {
   11     var info types.Info
   12     if pass.TypesInfo != nil {
   13         info = *pass.TypesInfo
   14     }
   15 
   16     prog := &loader.Program{
   17         Fset: pass.Fset,
   18         Created: []*loader.PackageInfo{
   19             {
   20                 Pkg:                   pass.Pkg,
   21                 Importable:            true, // not used
   22                 TransitivelyErrorFree: true, // TODO ???
   23 
   24                 Files:  pass.Files,
   25                 Errors: nil,
   26                 Info:   info,
   27             },
   28         },
   29         AllPackages: map[*types.Package]*loader.PackageInfo{
   30             pass.Pkg: {
   31                 Pkg:                   pass.Pkg,
   32                 Importable:            true,
   33                 TransitivelyErrorFree: true,
   34                 Files:                 pass.Files,
   35                 Errors:                nil,
   36                 Info:                  info,
   37             },
   38         },
   39     }
   40     return prog
   41 }