mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-12 16:15:24 +00:00
24 lines
490 B
Go
24 lines
490 B
Go
//go:build sqlite || sqliteonly
|
|
|
|
package sqlitestore
|
|
|
|
import "fmt"
|
|
|
|
// sqliteJSONValue accepts JSON stored by SQLite as either TEXT or BLOB.
|
|
type sqliteJSONValue []byte
|
|
|
|
// Scan implements sql.Scanner.
|
|
func (j *sqliteJSONValue) Scan(src any) error {
|
|
switch value := src.(type) {
|
|
case nil:
|
|
*j = nil
|
|
case string:
|
|
*j = append((*j)[:0], value...)
|
|
case []byte:
|
|
*j = append((*j)[:0], value...)
|
|
default:
|
|
return fmt.Errorf("sqliteJSONValue: unsupported type %T", src)
|
|
}
|
|
return nil
|
|
}
|