'How to get Returning value in Gorm Postgress

I have created an serial_num (auto incremented/ serial type ) column in our postgress db. my contact struct type is as of below and i am using upsert operation

var Contact struct {
  RowID             string `gorm:"primaryKey"`
  FirstName         string
}

during upsert with above struct serial_num is automatically populated in my table. I need to get corresponding those serial num after upsert. I am using returning cluase

db2.Clauses(
    clause.OnConflict{ UpdateAll: true,},
    clause.Returning{
        Columns: []clause.Column{
            {Name: "serial_num"}
        }
    })
.Create(&contact)

But i dont know how to get this returning serial_num in a variable



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source