fix: enhance PrivateString Scan method to support []byte input (#324)

Signed-off-by: Dmytro Bondar <git@bonddim.com>
This commit is contained in:
Dmytro Bondar 2024-11-26 21:09:39 +01:00 committed by GitHub
parent f7c3bdf456
commit 90a570bd66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,11 +36,14 @@ func (ps *PrivateString) Scan(value interface{}) error {
*ps = ""
return nil
}
strValue, ok := value.(string)
if !ok {
switch v := value.(type) {
case string:
*ps = PrivateString(v)
case []byte:
*ps = PrivateString(string(v))
default:
return errors.New("invalid type for PrivateString")
}
*ps = PrivateString(strValue)
return nil
}