go.nvim icon indicating copy to clipboard operation
go.nvim copied to clipboard

gofumpt/golines/goimports failed 1/2

Open nrydanov opened this issue 1 year ago • 5 comments

I constantly get messages like gofumpt failed 2 on save.

I see [Wed Nov 6 00:28:27 2024 582068]  ....living/.local/share/nvim/lazy/go.nvim/lua/go/format.lua:75 |1: { "stat /Users/find.art.in.living/Documents/dev/work/orb/runner/cmd/main.go: no such file or directory" } from stderr in logs.

However, this path exists if I just copy it and open Neovim, for example.

my go.nvim config

return {
    "ray-x/go.nvim",

    event = { "CmdlineEnter" },
    config = function()
        require("go").setup({
            goimports = "golines",
             verbose = true,
                gofmt = "gofumpt",
                log_path = vim.fn.expand("$HOME") .. "/tmp/gonvim.log",
            lsp_cfg = true,
            lsp_inlay_hints = {
                enable = false,
            }
        })

        local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})
        vim.api.nvim_create_autocmd("BufWritePre", {
            pattern = "*.go",
            callback = function()
                require('go.format').gofmt()
            end,
            group = format_sync_grp,
        })
    end,
    ft = { "go", 'gomod' },
}

nrydanov avatar Nov 05 '24 20:11 nrydanov

The configuration looks fine. Is the file linked to another file or is it in a cloud shared folder?

ray-x avatar Nov 05 '24 22:11 ray-x

The configuration looks fine. Is the file linked to another file or is it in a cloud shared folder?

It is existing file on my local drive.

nrydanov avatar Nov 06 '24 13:11 nrydanov

Same error when using goimports imports option.

[Fri 27 Dec 2024 10:45:27 PM MSK 80466]   ...re/nvim/site/pack/packer/start/go.nvim/lua/go/format.lua:156 |1: imports |2: {}
 |3: goimports
[Fri 27 Dec 2024 10:45:27 PM MSK 80515]   ...re/nvim/site/pack/packer/start/go.nvim/lua/go/format.lua:35 |1: {}
 |2: 2 |3: goimports
[Fri 27 Dec 2024 10:45:27 PM MSK 94510]   ...re/nvim/site/pack/packer/start/go.nvim/lua/go/format.lua:50 |1: formatting buffer... { "/home/username/project/internal/pkg/service/processor/bridge/bridge.go" } |2: 1
[Fri 27 Dec 2024 10:45:27 PM MSK 94557]   ...re/nvim/site/pack/packer/start/go.nvim/lua/go/format.lua:54 |1: fmt cmd: |2: { "goimports", "/home/username/project/internal/pkg/service/processor/bridge/bridge.go" }

[Fri 27 Dec 2024 10:45:27 PM MSK 109606]   ...re/nvim/site/pack/packer/start/go.nvim/lua/go/format.lua:75 |1: { "stat /home/username/project/internal/pkg/service/processor/bridge/bridge.go: no such file or directory" } from stderr

cl1ckname avatar Dec 27 '24 19:12 cl1ckname

When running commands from the command line,

goimports /home/username/project/internal/pkg/service/processor/bridge/bridge.go
stat /home/username/project/internal/pkg/service/processor/bridge/bridge.go

Is the output expected?

ray-x avatar Feb 10 '25 14:02 ray-x

Yes, it is

cl1ckname avatar Feb 10 '25 16:02 cl1ckname