You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hugobot/types/stringlist.go

29 lines
473 B
Go

package types
import (
"database/sql/driver"
"errors"
"strings"
)
type StringList []string
func (sl *StringList) Scan(src interface{}) error {
switch v := src.(type) {
case string:
*sl = strings.Split(v, ",")
case []byte:
*sl = strings.Split(string(v), ",")
default:
return errors.New("Could not scan to []string")
}
return nil
}
func (sl StringList) Value() (driver.Value, error) {
result := strings.Join(sl, ",")
return driver.Value(result), nil
}