Goinsta mgo code error review

hi i got multiple-value c.Upsert() in single-value context with item.ID

my code is :

package main

import (
	e "gopkg.in/ahmdrz/goinsta.v2/examples"

func main() {
	session, err := mgo.Dial("")
	if err != nil {
	defer session.Close()
	session.SetMode(mgo.Monotonic, true)
	c := session.DB("tanzen").C("monitoring")
	inst, err := e.InitGoinsta("")
	media := inst.Timeline.Get()
	for i := 0; i < 500; i++ {
		fmt.Println("Next:", media.NextID)
		for _, item := range media.Items {
			fmt.Printf("%+v\n", item.User.FullName)
			colQuerier := bson.M{"id": item.ID}
			err = c.Upsert(colQuerier, item)
			if err != nil {
	if !e.UsingSession {
		err = inst.Logout()

this is my first time using golang, thank you

@swinggame Could you be more descriptive in your question?

Haven’t used mgo much other than support it in a project, but checking the docs it appears the Collection’s Upsert method signature mentions 2 return values, a *ChangeInfo and an error, which you are trying to assign to a single value. So instead of this:

err = c.Upsert(colQuerier, item)

You should have this if you don’t need to do something with the ChangeInfo pointer:

_, err = c.Upsert(colQuerier, item)

Or something like this and then use ci later:

ci, err := c.Upsert(colQuerier, item)

i’m confused about this part,

Hi @swinggame,

@iegomez explained it well.

In GoLang a function or a method can return multiple values, and when they do you have to accept it in multiple values, you can’t store two different value in single variable, i.e., if you have one string and one integer value, you need two variable one to store string value and another to store integer value.

c, d := "Hello",5    // assigns string value "Hello" to variable c, and integer value 5 to d.
fmt.Println(c, d)    // will print - Hello 5

you can’t do this:
d := "Hello",5 // Golang has no idea, that which values should go in variable d

Please go through some example where a function returns multiple values play with that to get the better understanding, some links : gobyexample.com, tour.golang.org

If one of the return value doesn’t matter to you, you can simply discard with underscore variable (_), which is also called blank identifier blank identifier

you can do this:
_ , d := "Hello",5 // if you are not interested in "Hello" and simply want to discard
but then you won’t be able to do this:
fmt.Println(_, d)

but this will work:
fmt.Println( d)

Hope this explains