-
Notifications
You must be signed in to change notification settings - Fork 223
Open
Description
Describe the bug
type User struct {
// Model embeds common database fields (ID, CreatedAt, UpdatedAt, DeletedAt)
// that are shared across most entity types in the system
// These fields automatically track creation, update, and deletion timestamps
Model // Embedded base model with ID and timestamp fields (created_at, updated_at, deleted_at)
// UserName is the unique identifier for the user in the system.
// It must not be empty and is indexed in the database.
// This field is used for login purposes and must be unique across all users.
// Validation ensures this field is never empty before persistence.
// Users will use this value to identify themselves during authentication.
// The uniqueness constraint prevents duplicate registrations and ensures system integrity.
UserName string `json:"username" xml:"username" yaml:"username" toml:"username" schema:"username" gorm:"column:username;not null;uniqueIndex:user_ids;default:'';"`
...
// Model represents the base structure that other domain models can embed.
// It provides standard fields for identification, creation time, update time,
// and soft deletion support through GORM's DeletedAt field.
type Model struct {
// ID is the primary key for the model record in the database.
ID id.ID `json:"id" xml:"id" yaml:"id" toml:"id" schema:"id" gorm:"primaryKey;autoIncrement;column:id"`
// CreatedAt stores the timestamp when the record was initially created.
CreatedAt time.Time `json:"created_at,omitempty" xml:"created_at,omitempty" yaml:"created_at,omitempty" toml:"created_at,omitempty" schema:"created_at,omitempty" gorm:"column:created_at"`
// UpdatedAt stores the timestamp when the record was last updated.
UpdatedAt time.Time `json:"updated_at,omitempty" xml:"updated_at,omitempty" yaml:"updated_at,omitempty" toml:"updated_at,omitempty" schema:"updated_at,omitempty" gorm:"column:updated_at"`
// DeletedAt supports soft deletion (when set, the record is considered deleted).
DeletedAt gorm.DeletedAt `json:"deleted_at,omitempty" xml:"deleted_at,omitempty" yaml:"deleted_at,omitempty" toml:"deleted_at,omitempty" schema:"deleted_at,omitempty" gorm:"index;column:deleted_at"`
}
To Reproduce
when i try to Marshal with toml, CreatedAt, UpdatedAt are skipped.
CreatedAt, UpdatedAt should be output after id.
version = '0.1'
code = 200
message = 'OK'
timestamp = 1747452058
requestid = 'd0k016ljcs8dudumnd40'
[data]
page = 1
limit = 30
total = 1
[[data.list]]
id = 1
username = 'snowdream'
Expected behavior
A clear and concise description of what you expected to happen, if other than "should work".
Versions
- go-toml: github.com/pelletier/go-toml/v2 v2.2.4
- go: go version
go version go1.23.6 darwin/amd64 - operating system: e.g. macOS
Additional context
Add any other context about the problem here that you think may help to diagnose.
Metadata
Metadata
Assignees
Labels
No labels