Jquery Developer
Jquery Developer

Reputation: 279

Go method fails : multiple-value in a single value context

I have the following struct:

type OpList struct  {
    Name   xml.Name `xml:"Ser"`
    Servs []Ser `xml:"Ser"`
}

I have a method:

func GetInfo() (*OpList, error){  
    //If I print here the results gets printed
    fmt.Println(OpList.Servs)
    return OpList, nil
}

Accessing the list works absolutely fine inside of the method

But when I call this method and try to access it fails with the message: multiple-value in a single value context

bn:=GetInfo()
fmt.Printf(bn.Servs)

I am actually not getting that much information in net as well. How do I access the value returned from a typical method like this?

Upvotes: 0

Views: 716

Answers (1)

Emil Davtyan
Emil Davtyan

Reputation: 14089

Try :

bn, err := GetInfo()
fmt.Printf(bn.Servs)

Upvotes: 6

Related Questions