Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go mod initialize to avoid "malformed import path" UX #3273

Open
kaihendry opened this issue Aug 7, 2021 · 6 comments
Open

Go mod initialize to avoid "malformed import path" UX #3273

kaihendry opened this issue Aug 7, 2021 · 6 comments

Comments

@kaihendry
Copy link

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

@bhcleek
Copy link
Collaborator

bhcleek commented Aug 8, 2021

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

@bhcleek
Copy link
Collaborator

bhcleek commented Aug 8, 2021

FWIW, I think this behavior may change in a future release of Go. golang/go#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.

@bitwombat
Copy link

bitwombat commented Mar 13, 2022

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.

@mlliarm
Copy link

mlliarm commented Apr 15, 2023

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)                                                             
 } 

@bitwombat
Copy link

Did you go mod init ?

@mlliarm
Copy link

mlliarm commented Apr 16, 2023

Did you go mod init ?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants