On Sat, Dec 7, 2019 at 9:12 AM kr c <
xnzm...@gmail.com> wrote:
>
>
https://play.golang.org/p/mqpT8XBbeiN
>
> Hi, Everyone! I'm newbie in go. Help needed.
> As far as I learned, gorutines should pass "value" through channels.
> There's more safe way to handle this kind of stuffs with using waitgroup, context, channels....I thought, "sharing variable reference in gorutine" is dangerous because of problems like transacion issue.
>
> But what if that value is just single error? Is it still unsafe or may cause panic?
>
> "longTask" in examples is a task that I can garantee it will eventually end.
> I know little about low level programming. So not sure if I can write this kind of code.
That program is not safe. There is a race condition between writing
to rerr in the goroutine and reading rerr in the deferred function. I