MCPcopy Create free account
hub / github.com/Melkeydev/govm / ListVersions

Function ListVersions

internal/cli/cli.go:73–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71 }
72}
73func ListVersions() {
74 fmt.Println("📋 Installed Go Versions:")
75 homeDir, err := os.UserHomeDir()
76 if err != nil {
77 fmt.Printf("❌ Error getting home directory: %v\n", err)
78 return
79 }
80 activeVersion := ""
81 activeVersionFile := filepath.Join(homeDir, ".govm", "active_version")
82 if versionBytes, err := os.ReadFile(activeVersionFile); err == nil {
83 activeVersion = string(versionBytes)
84 }
85 goVersionsDir := filepath.Join(homeDir, ".govm", "versions")
86 if _, err := os.Stat(goVersionsDir); os.IsNotExist(err) {
87 fmt.Println(" No versions installed yet")
88 return
89 }
90 entries, err := os.ReadDir(goVersionsDir)
91 if err != nil {
92 fmt.Printf("❌ Error reading versions directory: %v\n", err)
93 return
94 }
95 if len(entries) == 0 {
96 fmt.Println(" No versions installed yet")
97 return
98 }
99 for _, entry := range entries {
100 if entry.IsDir() && strings.HasPrefix(entry.Name(), "go") {
101 version := strings.TrimPrefix(entry.Name(), "go")
102 if version == activeVersion {
103 fmt.Printf(" %s %s\n", version, "✓ (active)")
104 } else {
105 fmt.Printf(" %s\n", version)
106 }
107 }
108 }
109 fmt.Println("\nTo install a new version: govm install <version>")
110 fmt.Println("To switch versions: govm use <version>")
111}
112func findMatchingVersion(version string) (utils.GoVersion, error) {
113 msg := utils.FetchGoVersions()
114 versions, ok := msg.(utils.VersionsMsg)

Callers 1

handleCommandLineFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected