In the GORM documentation for reference and foreign key
https://gorm.io/docs/belongs_to.html
What does a foreign key do?
what does a reference do?
What is the difference between a foreign key and reference?
In the GORM documentation for reference and foreign key
https://gorm.io/docs/belongs_to.html
What does a foreign key do?
what does a reference do?
What is the difference between a foreign key and reference?
Using the example in the link you provided, User belongs to Company and CompanyID is the foreign key
The foreign key is a field in the child model (e.g., User.CompanyID) that stores the ID of the related parent model (e.g., Company.ID), linking the two models.
The references tag tells GORM which field in the parent model (e.g., Company.Code) the foreign key should reference, instead of the default primary key (ID).