listLocalVersions List the versions in the specified directory in ascending order
(dirPath string)
| 51 | |
| 52 | // listLocalVersions List the versions in the specified directory in ascending order |
| 53 | func 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 | } |
searching dependent graphs…