这是我的字段定义 type StationInfo struct { Id uuid.UUID gorm:"column:id;type:char(36)" Name string gorm:"column:name" Dtu string gorm:"column:DTU_id" }

数据库中的ID字段值为:5208cffa-7943-11ea-bc53-005056c00008 而通过gorm查询出的ID字段值为:facf0852-4379-ea11-bc53-005056c00008

Comment From: iwaters-yyj

数据库驱动为:gorm.io/driver/sqlserver

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: a631807682

duplicated of https://github.com/go-gorm/gorm/issues/5419

Comment From: hugh2632

`import ( "database/sql/driver" mssql "github.com/microsoft/go-mssqldb" )

type Guid struct { guid mssql.UniqueIdentifier }

func (j *Guid) Scan(value interface{}) error { return j.guid.Scan(value) }

func (j Guid) Value() (driver.Value, error) { return j.guid.Value() }

func (j Guid) String() string { return j.guid.String() }

func (j Guid) MarshalText() ([]byte, error) { return []byte(j.guid.String()), nil }` This works for me. Substitute uuid.UUID with this Guid struct.