Go development with vim and vim-go on Rocky Linux 9

Hello,

I’ve set up Rocky on one of my machines recently to do some Go development.

Here are a few notes on setting up my Rocky installation. I hope you’ll find in useful and please feel free to ask questions and add your suggestions.

Rocky Linux

I’ve installed Rocky Linux 9.1 GNOME (Lite Workstation) — this can be found on the Alternative Images download page.

Go

Install Go with the following:

sudo dnf install golang-bin

Update PATH for Go. I created the file ~/.bashrc.d/go.bash with the following contents:

# Check if `go` command exists
if hash go &> /dev/null
then
    gopath="$(go env GOPATH)/bin"
    if ! [[ "$PATH" =~ "${gopath}:" ]]
    then
        PATH="${gopath}:$PATH"
    fi
    unset gopath
fi
export PATH

Restart your terminal to apply the changes.

Vim and vim-go

I’m a long-time vim user, so I decided to use vim-go plugin. So, I installed all the packages with:

sudo dnf install vim-enhanced vim-go

Note: vim-go requires EPEL repo to be enabled.

For its functionality vim-go plugin depends on some tools. To install those tools you advised to start vim and run :GoInstallBinaries.

However, running that command leads to error messages during the installation of some tools. Let’s try to install those tools manually:

$ go install -v -mod=mod github.com/mgechev/revive@latest
$ go install -v -mod=mod golang.org/x/tools/gopls@latest
$ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
$ go install honnef.co/go/tools/cmd/staticcheck@2022.1.3
1 Like

With Rocky Linux 9.2 released yesterday now we have go1.19.6. But still :GoInstallBinaries outputs error messages during the installation of some of the tools.

Here’s a slightly updated snippet of commands to install the rest of the tools:

$ go install -v -mod=mod github.com/mgechev/revive@latest
$ go install -v -mod=mod golang.org/x/tools/gopls@latest
$ go install -v -mod=mod github.com/golangci/golangci-lint/cmd/golangci-lint@latest

Also, I filed an upstream issue on GitHub.

1 Like

The problem is that EPEL 9 ships slightly old version — vim-go 1.26

The issue with :GoInstallBinaries was fixed in v1.27 (CHANGELOG)

vim-go-1.28 is available for both Fedora 37 and 38

So, I’m going to request for EPEL package update

https://bugzilla.redhat.com/show_bug.cgi?id=2208452

vim-go 1.28 is now finally in EPEL 9 :tada:

So, now :GoInstallBinaries works correct out of the box!