add documentation
This commit is contained in:
@@ -7,26 +7,23 @@ import (
|
||||
"golang.org/x/mod/modfile"
|
||||
)
|
||||
|
||||
type logger interface {
|
||||
Logf(f string, s ...interface{})
|
||||
Debugf(f string, s ...interface{})
|
||||
}
|
||||
|
||||
// GoMod represents a Go Modules parser.
|
||||
// Running LoadAndComputePairs with a filename will return a slice of parsed dependencies.
|
||||
type GoMod struct {
|
||||
IncludeIndirect bool
|
||||
ProxyLoader Queryer
|
||||
Logger logger
|
||||
}
|
||||
|
||||
func isReplaced(module string, replaces []*modfile.Replace) bool {
|
||||
for i := range replaces {
|
||||
if module == replaces[i].Old.Path {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
// logger is an extremely simple leveled logger
|
||||
type logger interface {
|
||||
Logf(f string, s ...interface{})
|
||||
Debugf(f string, s ...interface{})
|
||||
}
|
||||
|
||||
// LoadAndComputePairs takes a filename of a go.mod file,
|
||||
// runs the resolution algorithm in the provided Querier,
|
||||
// and returns parsed pairs of dependencies and their latest versions.
|
||||
func (g *GoMod) LoadAndComputePairs(filename string) ([]libyear.Pair, error) {
|
||||
b, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
@@ -59,3 +56,12 @@ func (g *GoMod) LoadAndComputePairs(filename string) ([]libyear.Pair, error) {
|
||||
}
|
||||
return pairs, nil
|
||||
}
|
||||
|
||||
func isReplaced(module string, replaces []*modfile.Replace) bool {
|
||||
for i := range replaces {
|
||||
if module == replaces[i].Old.Path {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user