dongxiane0395 2015-01-15 00:58
浏览 324
已采纳

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?

  • 写回答

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.

    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Erasure Code纠删码表
  • ¥15 用vite创建的vue3项目,404重定向不起作用??
  • ¥15 关于#c语言#的问题:一个球从80米高度自由落下,每次落地后反弹的高度为原高度的一半计算6次小球反弹的高度.(反弹结果取整,使用走走for循环结构)
  • ¥15 SurfaceControl的screenshot问题
  • ¥15 基于51单片机的oled菜单代码,要C语言,模块化编程!
  • ¥15 JAVAswing,设计一个扑克牌什么的
  • ¥50 python ctypes调用dll实现分析
  • ¥40 用python解决数据统计问题
  • ¥100 是否有方案能通过抓包分析得到移动应用的名称和包名信息?
  • ¥15 opencv检测不到轮廓