chatdesk-ui/auth_v2.169.0/internal/storage/helper.go

32 lines
513 B
Go

package storage
import (
"database/sql/driver"
"errors"
)
type NullString string
func (s *NullString) Scan(value interface{}) error {
if value == nil {
*s = ""
return nil
}
strVal, ok := value.(string)
if !ok {
return errors.New("column is not a string")
}
*s = NullString(strVal)
return nil
}
func (s NullString) Value() (driver.Value, error) {
if len(s) == 0 { // if nil or empty string
return nil, nil
}
return string(s), nil
}
func (s NullString) String() string {
return string(s)
}