Conversation
|
Your Render PR Server URL is https://engineering-handbook-pr-69.onrender.com. Follow its progress at https://dashboard.render.com/static/srv-ccic9e9gp3jjvdiit0f0. |
406f63b to
4b26694
Compare
5138e41 to
56a8c80
Compare
|
@qdm12 Might wanna add some go devs in company to review? |
56a8c80 to
4c78eaf
Compare
4c78eaf to
4f8550c
Compare
|
|
||
| This is also useful such that you can use the narrow interfaces (such as `Getter`) in unexported package-local functions. | ||
|
|
||
| ### Exported interfaces with exported methods only |
There was a problem hiding this comment.
@qdm12 could you maybe please elaborate this section even more? Maybe add examples to those 3 paths and some explanation.
And the ideal would be to refer the particular article or a section/post from go.dev.
| value := myInterface.(*myImplementation).GetValue() | ||
| ``` | ||
|
|
||
| Interfaces should have one or two methods. If you need a larger interface, compose it using smaller interfaces. For example: |
There was a problem hiding this comment.
curious about the reasoning for this? specifically that an interface should only have 1 or 2 methods?
noot
left a comment
There was a problem hiding this comment.
overall looks good, just one comment/question
| Instead do a type assertion on the interface to call the method. For example: | ||
|
|
||
| ```go | ||
| value := myInterface.(*myImplementation).GetValue() |
There was a problem hiding this comment.
Would be nice to assert whether or not myInterface is of the *myImplementation
| value := myInterface.(*myImplementation).GetValue() | |
| impl, ok := myInterface.(*myImplementation) | |
| assert.True(t, ok) | |
| value := impl.GetValue() |
There was a problem hiding this comment.
Not really, since it's a test you know in advance what implementation it is. And if not, panicing in the test is fine I'd say.
|
|
No description provided.