Skip to content

Correctly pass multiple return values as arguments to other functions #973

@gopherbot

Description

@gopherbot

by Erlan.Sergaziev:

What steps will reproduce the problem?
1. Compile this program
func main() {
    fmt.Printf("String: %s, Int: %d\n", multipleReturnValues())
}

func multipleReturnValues() (s string, i int) {
    return `String`, 10
}

What is the expected output?
String: String, Int: 10

What do you see instead?
Compile error:
multiple-value multipleReturnValues() in single-value context
cannot use multipleReturnValues() as type interface { } in function argument


What is your $GOOS?  $GOARCH?
linux, amd64

Which revision are you using?  (hg identify)
14 July Release

Please provide any additional information below.
It might be difficult to implement, but logically the compiler should know that the
function returns multiple values and pass them as separate arguments to Printf.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions