尝试使用updateId()时得到“未找到”

I am very new to golang. I decided to write a simple REST application. I am using MongoDB as a backend.

The POST and GET APIs are working as expected. However, when writing an API on which I want to do a PUT operation by given id, I am getting an error saying the id is "not found"

Any advice?

type Task struct {
   ID   bson.ObjectId `bson:"_id,omitempty" json:"id"`
    Name string        `bson:"name" json:"name"`
    Desc string        `bson:"desc" json:"desc"`
}

var Tasks = new(tasks)

type tasks struct{}

    func (tasks) Update(id, name, desc string) error {
        if err := common.DB.Tasks.UpdateId(bson.IsObjectIdHex(id),
            bson.M{"$set": bson.M{
                "name": name,
                "desc": desc,
            }}); err != nil {
            return err
        }
        return nil
    }

package common

import(
    "gopkg.in/mgo.v2"
)

type mongo struct {
    Tasks *mgo.Collection
}

var DB *mongo