vim-go icon indicating copy to clipboard operation
vim-go copied to clipboard

Go mod initialize to avoid "malformed import path" UX

Open kaihendry opened this issue 3 years ago • 6 comments

What did you do? (required: The issue will be closed when not provided)

Google search and hunt around :Go prefix for a go mod init type helper

What did you expect to happen?

A go.mod init helper like VScode's Go: Initialize go.mod https://youtu.be/6r08zGi38Tk?t=233

What happened instead?

Quit vim-go to run go mod init github.com/$myusername/$(basename $pwd)

Configuration (MUST fill this out):

vim-go version:

I don't know how to tell this with vim plugged. The latest?

Vim version (first three lines from :version):

NVIM v0.5.0 Build type: Release LuaJIT 2.0.5

Go version (go version):

go version go1.16.7 linux/amd64

kaihendry avatar Aug 07 '21 23:08 kaihendry

I'm not sure how useful this would be. One could easily run !go mod init from within vim.

bhcleek avatar Aug 08 '21 02:08 bhcleek

FWIW, I think this behavior may change in a future release of Go. https://github.com/golang/go/issues/36513 specifically addresses it and links to other relevant issues, too.

I take your point about having something like :GoModInit, but since such a command is a one time operation, I'm not sure it's worth adding it to vim-go.

bhcleek avatar Aug 08 '21 03:08 bhcleek

Absolute go beginner here, running into this early in my vim-go usage. go run works from CLI, :GoRun giving OP's error. All my fault of course, (needed to go mod init blah/blah), just possibly a UX improvement, as OP said.

bitwombat avatar Mar 13 '22 04:03 bitwombat

Hello,

I'm too getting this error [0] with a simple code [1], when doing :GoRun from within Vim, just after the installation of vim-go and then of all the required packages with :GoInstallBinaries. Not sure what I'm doing exactly wrong here, but I understand from the previous comment that this is expected behavior.

I'm running VIM 8.2 in Debian 11.

Is there a step I've missed between installing vim-go & the go packages and :GoRun ? Thanks.


[0]

malformed import path "go: go.mod file not found in current directory 
or any parent directory;  see 'go help modules'": invalid char ':'

[1]

package main                                                                   
 import "fmt"                                                                   
                                                                                
 func main() {                                                                  
     var i int = 8                                                              
     var pi *int                                                                
     fmt.Println(i)                                                             
     pi = &i                                                                    
     *pi = 5                                                                    
     fmt.Println(i)                                                             
 } 

mlliarm avatar Apr 15 '23 13:04 mlliarm

Did you go mod init ?

bitwombat avatar Apr 16 '23 10:04 bitwombat

Did you go mod init ?

Thanks, I hadn't realized that this was a necessary step. Checking...

mlliarm avatar Apr 16 '23 12:04 mlliarm