Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

golang.org/x/tools/gopls version need to update #2886

Closed
AlphaWong opened this issue Nov 5, 2019 · 7 comments
Closed

golang.org/x/tools/gopls version need to update #2886

AlphaWong opened this issue Nov 5, 2019 · 7 comments

Comments

@AlphaWong
Copy link

The golang package version has been updated

/home/alpha/works/pkg/mod/golang.org/x/tools/[email protected]/main.go:20:41: not enough arguments in call to cmd.New
	have (string, string, nil)
	want (string, string, []string, func(*source.Options))

original (v0.1.7)

// https://github.com/golang/tools/blob/gopls/v0.1.7/gopls/main.go#L20
tool.Main(context.Background(), cmd.New("gopls", "", nil), os.Args[1:])

latest

// https://github.com/golang/tools/blob/master/gopls/main.go#L22
tool.Main(ctx, cmd.New("gopls", "", nil, hooks.Options), os.Args[1:])

Library

original (v0.1.7)

https://github.com/golang/tools/blob/gopls/v0.1.7/internal/lsp/cmd/cmd.go#L71
func New(name, wd string, env []string) *Application {
	if wd == "" {
		wd, _ = os.Getwd()
	}
	app := &Application{
		cache:   cache.New(),
		name:    name,
		wd:      wd,
		env:     env,
		OCAgent: "off", //TODO: Remove this line to default the exporter to on
	}
	return app
}

latest

// https://github.com/golang/tools/blob/master/internal/lsp/cmd/cmd.go#L75
// latest
func New(name, wd string, env []string, options func(*source.Options)) *Application {
	if wd == "" {
		wd, _ = os.Getwd()
	}
	app := &Application{
		cache:   cache.New(options),
		name:    name,
		wd:      wd,
		env:     env,
		OCAgent: "off", //TODO: Remove this line to default the exporter to on
	}
	return app
}
@AlphaWong
Copy link
Author

this line should have a problem as the 0.1.7 and latest branch have breaking change

// https://github.com/microsoft/vscode-go/blob/e936903d648caa40f4bbc7a6d0e28aeb59aedd43/src/goLanguageServer.ts#L402
const defaultLatestVersion = semver.coerce('0.1.7');
const defaultLatestVersionTime = moment('2019-09-18', 'YYYY-MM-DD');
async function shouldUpdateLanguageServer(tool: Tool, path: string, makeProxyCall: boolean): Promise<boolean> {
	// Only support updating gopls for now.
	if (tool.name !== 'gopls') {
		return false;
	}

	// First, run the "gopls version" command and parse its results.
	// If "gopls" is so old that it doesn't have the "gopls version" command,
	// or its version doesn't match our expectations, prompt the user to download.
	const usersVersion = await goplsVersion(path);
	if (!usersVersion) {
		return true;
	}

	// We might have a developer version. Don't make the user update.
	if (usersVersion === '(devel)') {
		return false;
	}

	// Get the latest gopls version.
	let latestVersion = makeProxyCall ? await latestGopls(tool) : defaultLatestVersion;

@AlphaWong
Copy link
Author

workaround

# install gopls separately
go get golang.org/x/tools/[email protected]

@stamblerre
Copy link
Contributor

stamblerre commented Nov 5, 2019

@ramya-rao-a: I believe that #2877 will fix this issue. The problem is that if multiple packages installed depend on different versions of x/tools, the temporary go.mod file that is used to support Go 1.11 may cause conflicts. This shouldn't be much of a problem since gopls will be auto-updated, but it will be an issue for people installing multiple tools at once. Sorry I didn't notice this earlier, I thought the PR had already been merged.

@ramya-rao-a
Copy link
Contributor

0.11.9 has been published with the fix by @stamblerre in #2877

@ramya-rao-a
Copy link
Contributor

@AlphaWong Can you share if the fix in the latest version helps?

@AlphaWong
Copy link
Author

I check my vscode and find that my current version is 0.11.8
let me upgrade it and check it again

@AlphaWong
Copy link
Author

@ramya-rao-a it works. Thx community!

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants