简体   繁体   中英

Function will not return multiple returns - multiple-value in single-value context

Go refuses to return multiple returns. If I leave out the second return it works but I need the second return. How do I resolve?

Here is my call:

type Streaming struct{}

func main() {
    mySlice, dateList = getHgetallStreamingData()
}

Here is my function:

func getHgetallStreamingData(pair string, c redis.Conn) ([]Streaming, []time.Time) {    
    var mySlice []Streaming
    var dateList []time.Time
    return mySlice, dateList
 }

Here is my error:

multiple-value getHgetallStreamingData() in single-value context

The error must be coming from somewhere else. The code works like a charm:

package main

import "time"

type Streaming struct{}

func main() {
    _, _ = getHgetallStreamingData()
}

func getHgetallStreamingData() (s []Streaming, t []time.Time) {
    return
}

playground .

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