3 ms·
This. And there is one technique that would help in this. Too often I see code like "xyz := pkg1.SomeFunc(a, b, c)" that makes xyz's type non-evident, especial
by euroderf 2y ago
This. And there is one technique that would help in this.
Too often I see code like "xyz := pkg1.SomeFunc(a, b, c)" that makes xyz's type non-evident, especially when interfaces are involved.
Please write Go code like
var xyz pkg2.SomeType
xyz = pkg1.SomeFunc(a, b, c)
My 0.02€, YMMV.
- maleldil 2y agoI don't get it. Why not use a code editor that shows the inferred type on hover?
- spirit-sparrow 2y agoThat should not be an issue, unless the code is written in notepad. As for interfaces, a better approach is to return struct and accept interface in your functions wherever it is possible.
- linhns 2y agoSometimes it's better to to return interfaces, like contract style programming.