github github
stars 267
issues 11
subscribers 1
forks 12



7 months ago


Stand With Ukraine

Minimalistic plugin for Go development in Neovim written in Lua.

It's not an LSP tool, the main goal of this plugin is add go tooling support in Neovim.


Pre-dependency: go (tested on 1.17 and 1.18)

use {
  requires = { -- dependencies

Also, run TSInstall go if go parser if isn't installed yet.


By .setup function you can configure the plugin.


  • installer does not install the tool in user set path
require("gopher").setup {
  commands = {
    go = "go",
    gomodifytags = "gomodifytags",
    gotests = "~/go/bin/gotests", -- also you can set custom command path
    impl = "impl",
    iferr = "iferr",


  1. Installation requires this go tool:

It will install next tools:

  1. Modify struct tags: By default json tag will be added/removed, if not set:
:GoTagAdd json " For add json tag
:GoTagRm yaml " For remove yaml tag
  1. Run go mod command:
:GoMod tidy " Runs `go mod tidy`
:GoMod init asdf " Runs `go mod init asdf`
  1. Run go get command

Link can have a http or https prefix.

You can provide more than one package url:

:GoGet github.com/gorilla/mux
  1. Interface implementation

Command syntax:

:GoImpl [receiver] [interface]

" Also you can put cursor on the struct and run:
:GoImpl [interface]

Example of usage:

" Example
:GoImpl r Read io.Reader
" or simply put your cursor in the struct and run:
:GoImpl io.Reader
  1. Generate tests with gotests

Generate one test for a specific function/method:


Generate all tests for all functions/methods in current file:


Generate tests only for exported functions/methods in current file:

  1. Run go generate command;
" Run `go generate` in cwd path

" Run `go generate` for current file
:GoGenerate %
  1. Generate doc comment

First set a cursor on public package/function/interface/struct and execute:

  1. Generate if err

Set cursor on the line with err and execute:

  1. Setup nvim-dap for go in one line.

Notice: nvim-dap is required



PRs are always welcome. See CONTRIBUTING.md