# The case of the old gopls

**URL:** <https://community.tmpdir.org/t/the-case-of-the-old-gopls/1448>\
**Category:** Software\
**Tags:** lsp, go\
**Created:** [December 27, 2024, 3:17pm UTC](https://community.tmpdir.org/t/the-case-of-the-old-gopls/1448 "2024-12-27T15:17:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cbrake](https://community.tmpdir.org/user_avatar/community.tmpdir.org/cbrake/32/3_2.png) [@cbrake](https://community.tmpdir.org/u/cbrake)\
**Post date:** [December 27, 2024, 3:17pm UTC](https://community.tmpdir.org/t/the-case-of-the-old-gopls/1448/1 "2024-12-27T15:17:33Z")

</div>

I recently started a new Go project and the language server would not work in Helix. It worked fine in other projects. I tried everything – removing modules one by one, etc. I then fired up VS Code and it did not work there. I eventually noticed an error popping up momentarily that that gopls needed re-complied for Go 1.23. It turns out I had installed `gopls` using `go get/install` some time ago:

`go install golang.org/x/tools/gopls@latest`

While this is very handy, it tends to never get updated unless you have problems.

Arch packages `gopls`, so it was a simple matter to install the Arch packaged version and everything works fine. Now I’ll always be running the latest version of Go and gopls, and they should match.

The `go.mod` file specifies the Go version. In the case of my older projects, they contained `go 1.20` whereas the new project contained `go 1.23`. So that is why gopls worked with the older projects and not newer – the different version specified in `go.mod`.

I did [some digging](https://www.perplexity.ai/search/what-does-the-go-version-in-go-W7279oZrROiuVhMr8aF1cQ) into what the Go compiler does with the go version in `go.mod`:

> When you have Go 1.23 installed on your system but your go.mod file specifies Go 1.20, the newer compiler (1.23) supports the older version (1.20) through a feature called “toolchain management.” This feature ensures backward compatibility and allows developers to work with projects using different Go versions.
> 
> Here’s how it works:
> 
> ## Toolchain Management
> 
> The Go compiler uses the version specified in the go.mod file to determine which language features and behaviors to enable or restrict. This means:
> 
> 1. The compiler will limit itself to the features and behaviors available in Go 1.20, even though it’s capable of more recent features [4](https://go.dev/doc/manage-install).
> 2. It will maintain compatibility with the syntax, standard library functions, and language semantics of Go 1.20 [4](https://go.dev/doc/manage-install).
> 
> ## Backward Compatibility
> 
> Go’s strong commitment to backward compatibility plays a crucial role in this process:
> 
> - The Go 1 compatibility promise ensures that code written for earlier versions of Go 1.x will continue to compile and run correctly on newer versions [2](https://appliedgo.com/blog/using-multiple-go-versions).
> - This allows developers to use the latest Go compiler while still working on projects that target older Go versions [2](https://appliedgo.com/blog/using-multiple-go-versions).

---

<div class="post-metadata">

**Author:** ![bminer](https://community.tmpdir.org/user_avatar/community.tmpdir.org/bminer/32/337_2.png) [@bminer](https://community.tmpdir.org/u/bminer)\
**Post date:** [January 7, 2025, 12:54am UTC](https://community.tmpdir.org/t/the-case-of-the-old-gopls/1448/2 "2025-01-07T00:54:05Z")

</div>

Yeah, I’ve run into the same thing. `go install` is nice, but utilizing your OS package manager is often better. Sadly, I’m on Linux Mint where you need a tool like `godeb` to run the bleeding edge (Go 1.23.4 at the time of this writing).
