dongxiane0395
2015-01-15 00:58
浏览 239

goimports无法与vim-go插件配合使用

I followed the installation instructions here https://github.com/fatih/vim-go and ran goimports hello.go. The output was my code with the imported package but when I opened hello.go the file did not have the code for the imported package.

Am I missing something?

图片转代码服务由CSDN问答提供 功能建议

我按照此处的安装说明进行操作 https://github.com/fatih/vim-go 并运行 goimports hello.go 。 输出是我导入的程序包的代码,但是当我打开hello.go时,该文件没有导入程序包的代码。

我遗漏了什么吗?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dougang1967 2015-01-15 02:07
    已采纳

    try

    goimports -w=true hello.go
    

    to rewrite source instead of output to stdout

    点赞 打赏 评论
  • duanluwei9374 2018-03-18 02:47

    Open the following go source file with your vim.

    package main
    
    func main() {
        fmt.Println(strings.ToUpper("hello"))
    }
    

    Then run GoImports in vim command line, the file should be updated to:

    package main
    
    import (
        "fmt"
        "strings"
    )
    
    func main() {
        fmt.Println(strings.ToUpper("gopher"))
    }
    

    I am using mvim 8.0.1420 on macOS 10.13.2. And vim-go version is d2b0a234ffb5441a3488c78fe8e5f551ddbdd454.

    点赞 打赏 评论

相关推荐 更多相似问题