为什么这个 Go-Lang IntelliJ 插件和 Go 的语法不一致?
Why is this Go-Lang IntelliJ plugin is inconsistent with Go's syntax?
我是 Go 的新手,所以这可能是 Go 的问题,而不是 IntelliJ 的问题:我刚刚在 IntelliJ 14 中从 zipfile 设置 https://github.com/go-lang-plugin-org/go-lang-idea-plugin/。
我发现编译器与语法高亮不一致。
world, err := redis.String(c.Do("GET", "message1"))
if err != nil {
fmt.Println("key not found")
}
产生以下错误信息。
*not enough arguments in call to Redis.String.
仔细观察对 Redis.String 的调用,它似乎需要一个接口+args。
func String(reply interface{}, err error) (string, error) {
....
return "", fmt.Errorf("redigo: unexpected type for String, got type %T", reply)
}
因此,我可以通过简单地在调用末尾添加 "err" arg 来欺骗 IDE 删除错误消息,如下所示:
world, err := redis.String(c.Do("GET", "message1"), err)
但是唉!这 "fix" 让 go 编译器不高兴...并报告此消息(即使 IntelliJ 插件不会将此解释为错误)。
./t1.go:19: multiple-value c.Do() in single-value context
任何关于为什么 IntelliJ Go 插件需要两个参数,而 GoLang 只需要一个参数的任何想法,对于这个功能都会有很大帮助。
我是 Go 的新手,所以这可能是 Go 的问题,而不是 IntelliJ 的问题:我刚刚在 IntelliJ 14 中从 zipfile 设置 https://github.com/go-lang-plugin-org/go-lang-idea-plugin/。
我发现编译器与语法高亮不一致。
world, err := redis.String(c.Do("GET", "message1"))
if err != nil {
fmt.Println("key not found")
}
产生以下错误信息。
*not enough arguments in call to Redis.String.
仔细观察对 Redis.String 的调用,它似乎需要一个接口+args。
func String(reply interface{}, err error) (string, error) {
....
return "", fmt.Errorf("redigo: unexpected type for String, got type %T", reply)
}
因此,我可以通过简单地在调用末尾添加 "err" arg 来欺骗 IDE 删除错误消息,如下所示:
world, err := redis.String(c.Do("GET", "message1"), err)
但是唉!这 "fix" 让 go 编译器不高兴...并报告此消息(即使 IntelliJ 插件不会将此解释为错误)。
./t1.go:19: multiple-value c.Do() in single-value context
任何关于为什么 IntelliJ Go 插件需要两个参数,而 GoLang 只需要一个参数的任何想法,对于这个功能都会有很大帮助。