duanfu7840 2015-02-23 14:08
浏览 41
已采纳

为什么此Go-Lang IntelliJ插件与Go的语法不一致?

I'm somewhat new to Go, so this could be a Go problem, rather than an IntelliJ one: I've just set up https://github.com/go-lang-plugin-org/go-lang-idea-plugin/ from the zipfile, in IntelliJ 14.

I found that the compiler is inconsistent with the syntax highlighter.

world, err := redis.String(c.Do("GET", "message1"))
if err != nil {
    fmt.Println("key not found")
}

Yields the following error message.

*not enough arguments in call to Redis.String.

Looking closer at the call to Redis.String, it appears to take an interface+args.

func String(reply interface{}, err error) (string, error) {
     ....
    return "", fmt.Errorf("redigo: unexpected type for String, got type %T", reply)
}

And thus, I'm able to trick the IDE into removing the rror message, by simply adding an "err" arg to the end of the call, like so:

world, err := redis.String(c.Do("GET", "message1"), err)

But Alas! This "fix" makes the go compiler unhappy... and it reports this message (even though the IntelliJ plugin does not interpret this as an error).

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

Any thoughts on why the IntelliJ Go Plugin wants two args, wheresas GoLang only wants one arg, for this function would be of great help.

  • 写回答

1条回答 默认 最新

  • dqzuo0327 2015-02-23 14:17
    关注

    It's not a mistake you are making, it's just a problem that we currently have with that particular part of plugin which takes care of things like that.

    As per my answer, please watch the issues 1343 and 1222.

    Thank you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部