package colorful
import (
)
type HexColor Color
type errUnsupportedType struct {
got interface{}
want reflect.Type
}
func ( *HexColor) ( interface{}) error {
, := .(string)
if ! {
return errUnsupportedType{got: reflect.TypeOf(), want: reflect.TypeOf("")}
}
, := Hex()
if != nil {
return
}
* = HexColor()
return nil
}
func ( *HexColor) () (driver.Value, error) {
return Color(*).Hex(), nil
}
func ( HexColor) () string {
return Color().Hex()
}
func ( errUnsupportedType) () string {
return fmt.Sprintf("unsupported type: got %v, want a %s", .got, .want)
}
func ( *HexColor) ( []byte) error {
var string
if := json.Unmarshal(, &); != nil {
return
}
var , = Hex()
if != nil {
return
}
* = HexColor()
return nil
}
func ( HexColor) () ([]byte, error) {
return json.Marshal(Color().Hex())
}
func ( *HexColor) ( string) error {
var , = Hex()
if != nil {
return
}
* = HexColor()
return nil
}
func ( HexColor) () (interface{}, error) {
return Color().Hex(), nil
}
func ( *HexColor) ( func(interface{}) error) error {
var string
if := (&); != nil {
return
}
var , = Hex()
if != nil {
return
}
* = HexColor()
return nil
}