gorm uuid
package model
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type EntityUsers struct {
ID string `gorm:"primaryKey;"`
Fullname string `gorm:"type:varchar(255);unique;not null"`
Email string `gorm:"type:varchar(255);unique;not null"`
Password string `gorm:"type:varchar(255);not null"`
Active bool `gorm:"type:bool;default:false"`
CreatedAt time.Time
UpdatedAt time.Time
}
func (user *EntityUsers) BeforeCreate(db *gorm.DB) error {
user.ID = uuid.New().String()
return nil
}