1
0
mirror of https://github.com/strongdm/comply synced 2024-11-14 03:44:55 +00:00
comply/vendor/gopkg.in/blang/semver.v1/sql.go
2019-07-14 13:51:10 -03:00

32 lines
593 B
Go

package semver
import (
"database/sql/driver"
"fmt"
)
// Scan implements the database/sql.Scanner interface.
func (v *Version) Scan(src interface{}) (err error) {
var strVal string
switch src.(type) {
case string:
strVal = src.(string)
case []byte:
strVal = string(src.([]byte))
default:
return fmt.Errorf("Version.Scan: cannot convert %T to string.", src)
}
tmpv, err := Parse(strVal)
if err != nil {
return
}
*v = *tmpv
return
}
// Value implements the database/sql/driver.Valuer interface.
func (s Version) Value() (driver.Value, error) {
return s.String(), nil
}