-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: should go list -versions
list cached versions when GOPROXY=off?
#32337
Comments
I'm more than likely behind in the conversation, but to me |
Thanks @bcmills for filing this issue. A bit more context behind this feature request: I found using Go without network access became harder and requires more learning in module mode than in the old GOPATH mode. In module mode, the best I could do was to ensure they are in the module cache or somewhere Go can recognize as a file proxy, but that is still insufficient because many Go commands will not work unless I explicitly set Another option I thought about is to have another GOPROXY mode (maybe No matter what decision Go team makes on this specific issue, I hope improvement in user experience when using Go without network. |
The original implementation relies on 'go list' to download the deps. 'go list' is called by other request handler indirectly. This approach is unpredictable and 'go list' is black box to us. So it's better download the deps manually in 'ManageDeps', i.e. inside 'initialize' request handler. For security, set 'GO111MODULE=off' by default, 'GO111MODULE=off' will disable the deps download by inconsistencies. NOTE:'GO111MODULE=off' break the go langserver ability in some extent. The official option for disable the network access is setting 'GOPROXY=off' under mod mode, however this option will break the go langserver totally. Related issue: golang/go#32337
Users can set
GOPROXY=off
to disable module fetches. When that is set, however, they can still resolve versions that are already present in the local cache.However, it can be difficult to figure out what those versions actually are:
go list -versions -m $MODULE
produces unhelpful error output (#32335) if the module is not present in the proxy, and truncated output if the module is present:The workaround is to set
GOPROXY="file://$GOPATH/pkg/mod/cache/download"
before runninggo list
:Unfortunately, that's really not discoverable (Paul's example notwithstanding).
Instead, I propose that when
GOPROXY
is set tooff
,go list -versions
should list the versions that are available without consulting the proxy, as if the user had setGOPROXY="file://$GOPATH/pkg/mod/cache/download"
.I don't see any other reasonable behavior we could provide in that case, and that would turn an otherwise useless-in-context command into a useful one.
CC @jayconrod @hyangah @thepudds @myitcv @rsc
The text was updated successfully, but these errors were encountered: