Skip to content

x/tools/gopls: doesn't handle replace directive #40836

@wtask

Description

@wtask

go version go1.15 windows/amd64

Version: 1.48.0 (user setup)
Commit: db40434f562994116e5b21c24015a2e40b2504e6
Date: 2020-08-13T07:50:42.600Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.19041

Go extension 0.16.1

gopls version

golang.org/x/tools/gopls 0.4.4
    golang.org/x/tools/[email protected] h1:8djGYsaZ0ByP0vaXg4T+mnyfDcHpWKSZ+tpQSGv9ahk=

I have a project with sub-module. The main repo contains api folder, so the main go.mod contain replace directive like:

replace {repo-url}/api => ./api

And I can not understand several things how to make extension to work as expected:

  1. If I do not fix the api version manually, the go-command makes it version v0.0.0-00010101000000-000000000000, after go mod tidy. But vscode-go despite of replace and "special" module version value, opens old api-version references (ctrl+click) from global pkg/mod/ folder. Restarting the language server does not help to force using local api-folder.

  2. If I run go get -u in module context to update api to latest available version (v0.2.0-pre in my case) then the go.mod file is properly modified. BUT vscode-go continue to use old module version which is not required and is not exists in go.mod. Restarting the gopls, reloading vscode does not help - an older version of api-module is opened by ctrl+click on api-references.

What do I need to do to force extension work in this simple case? Who of them the vscode-go OR the gopls is ignoring the replace-directive?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions