Skip to content

GOROOT usage #16

@bradleygore

Description

@bradleygore

What is the problem?

Thanks for this utility - it's really slick!

I used to manage multiple go versions via go.dev instructions, installing all my versions in ~/sdk/go/<version>.

In with that, I would have my most-used go version wired up to GOROOT via my .zshrc file like export GOROOT=~/sdk/go/1.22.9, and in my editor (vscode - sorry, not cool enough for vim yet 😅) I'd have it wired up like "go.goroot": "/path/to/sdk/go/1.22.9" in workspace or profile settings.

I started using govm hoping it would make it easier to auto-wire stuff upon switching go versions.

I removed the export GOROOT= line from my .zshrc to test this out, then went to a go project and tried to do go run ./main.go. This results in errors:

go run ./main.go
cmd/main.go:4:2: package context is not in std (/Users/bgore/.govm/shim/src/context)
... many more similar errors

However, if I run it with GOROOT set to the path of the desired go version, it works fine:

GOROOT=/Users/bgore/.govm/versions/go1.23.7 go run ./main.go

Wondering if either I'm just missing something dumb that would already make this easier, or if it would make sense to update the shim to set the GOROOT for the actual call to go once it finds the currently in use version.

Thanks again 😄

Operating System

macOS Sonoma 14.7.4

Architecture Version (x86, x64, arm, etc)

arm

Steps to reproduce

  1. Use govm to switch to a given version of go
  2. Do not have .bashrc | .zshrc | etc.. auto-wire GOROOT to any specific go version.
  3. Navigate to a local go package that pulls in packages from std lib and try to go run it - should get errors about package missing from std lib.
  4. Define GOROOT for the call to go run as in GOROOT=path/to/.govm/versions/<version> go run ./main.go and see that it runs.

Relevant log output

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions