使用GORM,我是否可以将默认值设置为PostgreSQL函数?

I want something like:

type User struct {
    ID          int     `sql:"default:<myfunction>"`
}

Is this possible with GORM?

Have you tried it? You can do

time.Time `sql:"DEFAULT:current_timestamp"`

and it will use the "current_timestamp" function. If you want the default to be the string current_timestamp, you would do

time.Time `sql:"DEFAULT:'current_timestamp'"`

So, in short, yes, it is possible. You would just do:

type User struct {
    ID          int     `sql:"DEFAULT:myfunction"`
}