MCPcopy Index your code
hub / github.com/voidint/g / listLocalVersions

Function listLocalVersions

cli/ls.go:53–72  ·  view source on GitHub ↗

listLocalVersions List the versions in the specified directory in ascending order

(dirPath string)

Source from the content-addressed store, hash-verified

51
52// listLocalVersions List the versions in the specified directory in ascending order
53func listLocalVersions(dirPath string) ([]*version.Version, error) {
54 dirs, err := os.ReadDir(dirPath)
55 if err != nil {
56 return nil, errors.WithStack(err)
57 }
58 items := make([]*version.Version, 0, len(dirs))
59 for _, d := range dirs {
60 if !d.IsDir() {
61 continue
62 }
63
64 v, err := version.New(d.Name())
65 if err != nil || v == nil {
66 continue
67 }
68 items = append(items, v)
69 }
70 sort.Sort(version.Collection(items)) // asc order
71 return items, nil
72}

Callers 3

TestListLocalVersionsFunction · 0.85
listFunction · 0.85
useFunction · 0.85

Calls 3

NewFunction · 0.92
CollectionTypeAlias · 0.92
NameMethod · 0.65

Tested by 1

TestListLocalVersionsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…