简体   繁体   中英

Why is this Go-Lang IntelliJ plugin is inconsistent with Go's syntax?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM