如何为Gorm指定具有多列唯一索引的结构?

How do I define my structs to specify a multi-column unique index to Gorm in Go?

Such as:

type Something struct {
    gorm.Model
    First  string `sql:"unique_index:unique_index_with_second"`
    Second string `sql:"unique_index:unique_index_with_first"`
}

Are you trying to create a table so that the combination of First and Second is unique?

This should work :

type Something struct {
    ID uint
    gorm.Model
    First  string `gorm:"primary_key"`
    Second string `gorm:"primary_key"`
}