Documentation
¶
Index ¶
- Variables
- func CheckURL(url string) (status int, err error)
- func Close(c io.Closer, f func(err error))
- func IsSelectorExpr(expr ast.Expr) bool
- func PackageName(pkgType PackageType) string
- func WarnOnError(err error)
- type Codebase
- type Field
- type FieldMap
- type Function
- type Functions
- type GoFile
- type GoFileParser
- type GoMod
- type Import
- type ImportMap
- type Imports
- type Method
- type MethodMap
- type ModFile
- func (ModFile) CodeFacet()
- func (mf ModFile) GoVersion() string
- func (mf *ModFile) ImportPath() (s string)
- func (mf *ModFile) ModFile() *modfile.File
- func (mf *ModFile) Modules() []*Module
- func (mf ModFile) Name() string
- func (mf ModFile) PathVersion() module.Version
- func (mf ModFile) Require() []*modfile.Require
- func (mf *ModFile) SetModFile(f *modfile.File)
- func (mf ModFile) String() string
- func (mf ModFile) UniqueID() (uId string)
- func (mf ModFile) Version() (v string)
- type Module
- type ModuleArgs
- type ModuleGraph
- func (mg *ModuleGraph) AddDependentModule(pm *Module, args *ModuleArgs)
- func (mg *ModuleGraph) AddProjectModule(args *ModuleArgs) *Module
- func (mg *ModuleGraph) DispenseGoModByImportPath(importPath string) (m *Module)
- func (mg *ModuleGraph) DispenseGoModByPath(path string) (gm *Module)
- func (mg *ModuleGraph) DispenseLocalPackage(importPath, source string) (pkg *Package)
- func (mg *ModuleGraph) DispenseModule(name, path string) (m *Module)
- func (mg *ModuleGraph) DispenseModuleByImportPath(importPath string) (m *Module)
- func (mg *ModuleGraph) DispenseModuleByPath(path string) (m *Module)
- func (mg *ModuleGraph) DispensePackage(importPath, source string) (pkg *Package)
- func (mg *ModuleGraph) GetGoModByExactPath(path string) (gm *Module, found bool)
- func (mg *ModuleGraph) GetPackageByImportPath(importPath string) (pkg *Package)
- type ModuleMap
- type ModulePackage
- type ModulePackageMap
- type ModuleVersions
- type Package
- func (p Package) ExternalURL() (url string)
- func (p Package) GoModPath() (s string)
- func (p Package) LocalSourceDir() (dir string)
- func (p Package) Name() (s string)
- func (p Package) PartialClone() (pkg *Package)
- func (p Package) SetVersion(ver string)
- func (p Package) Source() (src string)
- func (p Package) StdLibSourceURL() (url string)
- func (p Package) String() (s string)
- func (p Package) VersionName() (s string)
- type PackageArgs
- type PackageDetails
- type PackageMap
- type PackageType
- type PackageVersion
- type PathMap
- type Project
- type SafeMap
- type StringModuleMap
- type Variable
- type Variables
- type VersionArgs
- type VersionMap
Constants ¶
This section is empty.
Variables ¶
var PackageTypeMap = map[string]PackageType{}
var PackageTypes = []PackageType{ InvalidPackage, StdLibPackage, GoModPackage, LocalPackage, ExternalPackage, }
var StderrWriter io.Writer = os.Stderr
Functions ¶
func IsSelectorExpr ¶
func PackageName ¶
func PackageName(pkgType PackageType) string
func WarnOnError ¶
func WarnOnError(err error)
Types ¶
type Codebase ¶
func NewCodebase ¶
type Field ¶
type GoFile ¶
type GoFile struct { scanner.File Package *Package ImportMap ImportMap Functions Functions //Types _archive.Types References map[string]struct{} // contains filtered or unexported fields }
func (*GoFile) AddReference ¶
func (*GoFile) HasFunctions ¶
func (*GoFile) PackageImportPath ¶
func (*GoFile) PackageName ¶
type GoFileParser ¶
type GoFileParser struct { Files scanner.Files ModuleGraph *ModuleGraph // contains filtered or unexported fields }
func NewGoFileParser ¶
func NewGoFileParser(mg *ModuleGraph, rootDir string) *GoFileParser
type ModFile ¶
type ModFile struct { scanner.File Content []byte ModuleGraph *ModuleGraph // contains filtered or unexported fields }
func NewModFile ¶
func (ModFile) CodeFacet ¶
func (ModFile) CodeFacet()
CodeFacet simply marks ModFile as implementing collector.CodeFacet
func (*ModFile) ImportPath ¶
func (*ModFile) Modules ¶
Modules returns a slice of Mod where the first element is the module and the rest are its required dependencies. m.modFile, hence the name.
func (ModFile) PathVersion ¶
PathVersion returns the module.Version stored in mf.modFile.ModuleArgs.Mod, however, we replace the .Path value with mf.Fullpath().
func (ModFile) Require ¶
Require returns the version of the module as defined in go.mod by the `module` statement
func (*ModFile) SetModFile ¶
func (ModFile) String ¶
String returns a string representation of ModFile for debugging and error messages.
type Module ¶
type Module struct { *Package *GoMod Parent *Module Module *Module ModuleGraph *ModuleGraph // contains filtered or unexported fields }
func (*Module) GoModDir ¶
GoModDir returns the path to the go.mod file for the module, WITHOUT the suffix "/go.mod".
func (*Module) GoModPath ¶
GoModPath returns the path to the go.mod file for the module, WITH the suffix "/go.mod".
func (*Module) MaybeFixGoVersion ¶
MaybeFixGoVersion checks to see if Go has a GitHub tag matching the version in the go.mod file, or if we need to embellish it. Embellishing it means either adding a ".0" to the end, or removing it. More embellishment may be needed in the future, if the Go team gets sloppier with their tagging.
func (*Module) Version ¶
func (m *Module) Version() *PackageVersion
func (*Module) VersionName ¶
type ModuleArgs ¶
type ModuleArgs struct { ModuleGraph *ModuleGraph Parent *Module Module *Module Name string PackageDir string Version string Path string GoVersion string PackageType PackageType }
type ModuleGraph ¶
type ModuleGraph struct { ModuleMap // contains filtered or unexported fields }
func NewModuleGraph ¶
func NewModuleGraph() *ModuleGraph
func (*ModuleGraph) AddDependentModule ¶
func (mg *ModuleGraph) AddDependentModule(pm *Module, args *ModuleArgs)
func (*ModuleGraph) AddProjectModule ¶
func (mg *ModuleGraph) AddProjectModule(args *ModuleArgs) *Module
func (*ModuleGraph) DispenseGoModByImportPath ¶
func (mg *ModuleGraph) DispenseGoModByImportPath(importPath string) (m *Module)
func (*ModuleGraph) DispenseGoModByPath ¶
func (mg *ModuleGraph) DispenseGoModByPath(path string) (gm *Module)
DispenseGoModByPath returns a module for a go.mod based upon a path that has the go.mod's path as a string prefix, e.g.:
For /foo/go.mod then /foo/bar/baz will return module for /foo/go.mod, Except if a /foo/bar/go.mod then it will return module for /foo/bar/go.mod, OTOH will return `nil` for path="github.com/example/project"
func (*ModuleGraph) DispenseLocalPackage ¶
func (mg *ModuleGraph) DispenseLocalPackage(importPath, source string) (pkg *Package)
DispenseLocalPackage will return a newly instantiated Package of Local or GoMod type, or will return a pointer to one if previously instantiated and stored in mg.modulePackageMap.
func (*ModuleGraph) DispenseModule ¶
func (mg *ModuleGraph) DispenseModule(name, path string) (m *Module)
DispenseModule returns a *Module given a module name and path to source file where imported
func (*ModuleGraph) DispenseModuleByImportPath ¶
func (mg *ModuleGraph) DispenseModuleByImportPath(importPath string) (m *Module)
func (*ModuleGraph) DispenseModuleByPath ¶
func (mg *ModuleGraph) DispenseModuleByPath(path string) (m *Module)
DispenseModuleByPath will return the applicable module for the given path.
func (*ModuleGraph) DispensePackage ¶
func (mg *ModuleGraph) DispensePackage(importPath, source string) (pkg *Package)
dispensePackage returns a *Module given a package name (w/o alias) and source file where imported
func (*ModuleGraph) GetGoModByExactPath ¶
func (mg *ModuleGraph) GetGoModByExactPath(path string) (gm *Module, found bool)
GetGoModByExactPath returns a module for a go.mod based upon an exact path
func (*ModuleGraph) GetPackageByImportPath ¶
func (mg *ModuleGraph) GetPackageByImportPath(importPath string) (pkg *Package)
type ModuleMap ¶
type ModuleMap map[string]*ModuleVersions
func (ModuleMap) GetPackageByImportPath ¶
func (ModuleMap) ImportPaths ¶
type ModulePackage ¶
type ModulePackage struct { Module *Module PackageMap PackageMap }
type ModulePackageMap ¶
type ModulePackageMap map[string]*ModulePackage
type ModuleVersions ¶
type ModuleVersions struct { VersionMap VersionMap Module *Module ModPath string GoMod bool }
func NewModuleVersions ¶
func NewModuleVersions() *ModuleVersions
type Package ¶
type Package struct { *PackageDetails ImportPath string // contains filtered or unexported fields }
Package holds the name used early in the pipeline; during parsing
func NewFlyweightPackage ¶
func (Package) ExternalURL ¶
ExternalURL returns a URL for an external package. Panics if the package is not external.
func (Package) LocalSourceDir ¶
func (Package) PartialClone ¶
PartialClone returns a cloned version of Package completely disconnected from any pointers, EXCEPT for maintaining Module and ModuleGraph as pointers.
func (Package) SetVersion ¶
func (Package) StdLibSourceURL ¶
StdLibSourceURL returns the source URL for a Go package. Adds a fragment #invalid-version if URL resolution failed.
func (Package) String ¶
String returns a textual representation of Package for error messages and database fields.
func (Package) VersionName ¶
type PackageArgs ¶
type PackageArgs struct { ModuleGraph *ModuleGraph Module *Module ImportPath string Directory string Type PackageType Version string }
type PackageDetails ¶
type PackageDetails struct { PackageVersion *PackageVersion Module *Module ModuleGraph *ModuleGraph // Directory contains the full path to the package's directory // TODO: Change this to relative path when all paths are changed to relative Directory *string Type PackageType }
PackageDetails holds values used later in the pipeline
type PackageMap ¶
func (PackageMap) HasPackage ¶
func (pm PackageMap) HasPackage(name string) bool
type PackageType ¶
type PackageType int
const ( InvalidPackage PackageType = 0 StdLibPackage PackageType = 1 GoModPackage PackageType = 2 LocalPackage PackageType = 3 ExternalPackage PackageType = 4 )
func (PackageType) ID ¶
func (pt PackageType) ID() int
func (PackageType) Name ¶
func (pt PackageType) Name() string
type PackageVersion ¶
func NewPackageVersion ¶
func NewPackageVersion(args *VersionArgs) *PackageVersion
func (PackageVersion) ExternalURL ¶
func (v PackageVersion) ExternalURL() (url string)
ExternalURL returns a URL for an external package at the given version. Panics if the package is not external.
func (PackageVersion) Source ¶
func (v PackageVersion) Source() (src string)
Source returns a string of its source, complete with a version where applicable
func (PackageVersion) StdLibSourceURL ¶
func (v PackageVersion) StdLibSourceURL() (url string)
StdLibSourceURL returns the source URL for a package for the Go version. Adds a fragment #invalid-version if URL resolution failed.
type Project ¶
func NewProject ¶
type SafeMap ¶
type SafeMap[K comparable, V any] struct { sync.RWMutex // contains filtered or unexported fields }
SafeMap is a generic map that uses sync.RWMutex for concurrency-safe access
func NewSafeMap ¶
func NewSafeMap[K comparable, V any]() *SafeMap[K, V]
NewSafeMap instantiates a new instance of for SafeMap{KeyType,ValueType], e.g.
myMap := NewSafeMap[int,string]()