package db import ( "database/sql/driver" "encoding/json" "fmt" ) type Strings []string func (c *Strings) Scan(value any) error { if value == nil { return nil } return json.Unmarshal(value.([]byte), c) } func (c Strings) Value() (driver.Value, error) { b, err := json.Marshal(c) return string(b), err } type NullString string func (this *NullString) Scan(value any) error { if value == nil { return nil } switch s := value.(type) { case []byte: *this = NullString(s) default: *this = NullString(fmt.Sprintf("%v", s)) } return nil } func (c NullString) Value() (driver.Value, error) { return c, nil }