...

Source file src/github.com/blang/semver/sql.go

Documentation: github.com/blang/semver

     1  package semver
     2  
     3  import (
     4  	"database/sql/driver"
     5  	"fmt"
     6  )
     7  
     8  // Scan implements the database/sql.Scanner interface.
     9  func (v *Version) Scan(src interface{}) (err error) {
    10  	var str string
    11  	switch src := src.(type) {
    12  	case string:
    13  		str = src
    14  	case []byte:
    15  		str = string(src)
    16  	default:
    17  		return fmt.Errorf("Version.Scan: cannot convert %T to string.", src)
    18  	}
    19  
    20  	if t, err := Parse(str); err == nil {
    21  		*v = t
    22  	}
    23  
    24  	return
    25  }
    26  
    27  // Value implements the database/sql/driver.Valuer interface.
    28  func (v Version) Value() (driver.Value, error) {
    29  	return v.String(), nil
    30  }
    31  

View as plain text