MCPcopy Create free account
hub / github.com/voidint/g / switchVersion

Function switchVersion

cli/install.go:179–192  ·  view source on GitHub ↗
(vname string)

Source from the content-addressed store, hash-verified

177}
178
179func switchVersion(vname string) error {
180 targetV := filepath.Join(versionsDir, vname)
181
182 // Recreate symbolic link
183 _ = os.Remove(goroot)
184
185 if err := mkSymlink(targetV, goroot); err != nil {
186 return errors.WithStack(err)
187 }
188 if output, err := exec.Command(filepath.Join(goroot, "bin", "go"), "version").Output(); err == nil {
189 fmt.Printf("Now using %s", strings.TrimPrefix(string(output), "go version "))
190 }
191 return nil
192}
193
194func mkSymlink(oldname, newname string) (err error) {
195 if runtime.GOOS == "windows" {

Callers 2

installFunction · 0.85
useFunction · 0.85

Calls 1

mkSymlinkFunction · 0.85

Tested by

no test coverage detected