Re:REST Servers in Go: Part 1 – standard library
by hellcow on Sunday January 17, 2021 @07:39AM
(#25810218)
The downside to this approach is that you're unable to know what fields you can use in your query without reading the GetTask function, and changes to the GetTask function can silently break all callers, since it's now a runtime error.
[ Parent
| on HN ]
Re:REST Servers in Go: Part 1 – standard library
by zemo on Sunday January 17, 2021 @05:37PM
(#25815941)
tbh I've been using this method for years and the first one has never been an issue, because practically speaking you should only expect to give a single struct with a field or two filled in if that field or combination of fields is unique. You probably need that level of domain knowledge about what you're working on elsewhere anyway, so it has never been a problem.
I mean ... for the second problem that's broadly true of making any changes to your data access layer since by definition your Go compiler is not going to, for example, check the validity of a SQL query. So ... yes? but that's not unique to this approach, that's true generally.