Error handling in read function #3
-
Not an issue but rather a question: How any other error besides Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
MarioCarrion
Dec 19, 2021
Replies: 1 comment
-
Hello! Great question and also it looks like I totally forgot to check other errors, thanks for calling that out. I approach this in two different ways:
Both implementations are here; to keep everything simple I'm only showing the example using I typically start with the function and then depending if I need more details about the read process I implement the type one. I hope that helps. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
MarioCarrion
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
Great question and also it looks like I totally forgot to check other errors, thanks for calling that out.
I approach this in two different ways:
select
together with the one for reading the values (errGroupWithErrChannel
)errGroupWithType
)Both implementations are here; to keep everything simple I'm only showing the example using
errgroup
, but usingsync
should be similar.I typically start with the function and then depending if I need more details about the read process I implement the type one.
I hope that helps.