gpt4 book ai didi

syntax - 为什么这个 Go-Lang IntelliJ 插件和 Go 的语法不一致?

转载 作者:数据小太阳 更新时间:2023-10-29 03:17:03 24 4
gpt4 key购买 nike

我对 Go 有点陌生,所以这可能是一个 Go 问题,而不是一个 IntelliJ 问题:我刚刚设置了 https://github.com/go-lang-plugin-org/go-lang-idea-plugin/来自 IntelliJ 14 中的 zipfile。

我发现编译器和语法高亮不一致。

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 的调用,它似乎采用了接口(interface)+参数。

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)

但是!这个“修复”让 go 编译器不高兴......并且它报告了这条消息(即使 IntelliJ 插件没有将其解释为错误)。

./t1.go:19: multiple-value c.Do() in single-value context

关于为什么 IntelliJ Go 插件需要两个参数,而 GoLang 只需要一个参数的任何想法,对于这个函数都会有很大帮助。

最佳答案

这不是您犯的错误,这只是我们目前处理此类事情的插件的特定部分存在的问题。

根据 my answer ,请关注问题13431222 .

谢谢。

关于syntax - 为什么这个 Go-Lang IntelliJ 插件和 Go 的语法不一致?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28684449/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com