Your Question

自定义数据类型,在查询的时候提示:[error] unsupported data type: &[],结果是正常的,但是会出现此错误提示。

  • Model
type PutUser struct {
    //... Other fields
    Tips StringArray `gorm:"type:json; not null" json:"tips"`
}
  • StringArray
type StringArray []string

func (s StringArray) Value() (driver.Value, error) {
    return json.Marshal(s)
}

func (s *StringArray) Scan(src interface{}) error {
    return json.Unmarshal(src.([]byte), s)
}

Expected answer

应该没有此提示。

Comment From: Licoy

fix

Comment From: hktalent

@Licoy 看上去和我的类似 #5413 使用1.8泛型

Comment From: Licoy

@hktalent 我的这个错误是自己的问题,所以就close了

Comment From: sherlockwhite

@hktalent 我的这个错误是自己的问题,所以就close了

怎么解决的 能说下吗