goimports没有使用vim-go插件

问题描述 投票:0回答:2

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

我错过了什么吗?

go vim vim-plugin
2个回答
1
投票

尝试

goimports -w=true hello.go

重写源而不是输出到stdout


1
投票

使用vim打开以下go源文件。

package main

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

然后在vim命令行中运行GoImports,该文件应更新为:

package main

import (
    "fmt"
    "strings"
)

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

我在macOS 10.13.2上使用mvim 8.0.1420。 vim-go版本是d2b0a234ffb5441a3488c78fe8e5f551ddbdd454

© www.soinside.com 2019 - 2024. All rights reserved.