pgtype
pgtype copied to clipboard
Misleading error message
There are misleading error messages in Set(src interface{}) in polygon.go, circle.go etc...
The error message cannot convert %v to T implies that other types can be converted. It should say that the function is not yet implemented.
I'm not sure about that. Saying it is not yet implemented implies that it could be implemented. But there are no standard Go types that could be mapped to those geometry types. Saying that type X cannot be converted to Y is correct... it's just it is true for all type X.
I suppose a better message might clarify that no types are convertible...
I think the string representation can be mapped to geometry types, or for example [][]float64 to polygon.
I can implement it and create a pull request.
I'm open to supporting some type being settable. Though I wouldn't do a [][]float64. The extra slice per point would be inefficient. I would use []pgtype.Vec2 instead. ... In fact, now I'm wondering why I didn't have Set() handle that originally... 🤷
I created a pull request for Polygon.Set(src interface{}) #63 If you find it adequate I can implement Set() for the other geometric types as well.
It's okay with the one change I mentioned. If you want to do something similar for the other geometric types that would be fine.