In my DB i have a table that require a coordinate value. such value is stored as a
Point DataType
however when i try to obtain such value, GO responds with an error:
unsupported Scan, storing driver.Value type []uint8 into type *models.Point
this is my Model
type Business struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Owner string `json:"owner,omitempty"`
Coordinates Point `json:"coordinates,omitempty"`
Reason string `json:"reason,omitempty"`
BusinessBranches []BusinessBranches `json:"reason,omitempty"`
}
and this is the Point type model
type Point struct {
X float64 `json:"lat"`
Y float64 `json:"lon"`
}
in my controller i call the selection of Business.
func (b *BusinessRepoImpl) Select() ([]models.Business, error) {
business_list := make([]models.Business, 0)
rows, err := b.Db.Query("SELECT id, name, owner, coordinates, reason FROM business")
if err != nil {
return business_list, err
}
for rows.Next() {
business := models.Business{}
err := rows.Scan(&business.ID, &business.Name, &business.Owner, &business.Coordinates, &business.Reason)
if err != nil {
fmt.Println(err)
break
}
business_list = append(business_list, business)
}
err = rows.Err()
if err != nil {
return business_list, err
}
return business_list, nil
}
anyone know how to parse such DataType, so i can read it and store it? Thanks. :)