On Wed, 20 Apr 2022 at 23:29, Arthur Comte <ad...@arthurcomte.com> wrote:

> Actually, even with proper error handling, I still need to return a value.
> In some functions I can just return a variable that was defined in the
> function, but that is not always available. In those cases, the only
> solution I've found is to use `*new(E)`, which seems plain terrible. Is
> there an alternative? I'm guessing something is wrong with my angle
>

FWIW I've been using `*new(E)` throughout, on the understanding that sooner
or later there will be a proposal implemented that makes that simpler, and
when that does happen, it'll be trivial to do  `gofmt -w -r '*new(x) ->
zero` (for whatever spelling of "zero" is chosen), leaving the code exactly
as you'd have wanted to have written it in the first place with no need for
manual tidy-ups. Yes, it's crude for the time being, but at least it's
unambiguous.

-- 
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/CAP1AJ8fqT0yxd2g8gctPA%2B6Ei-fKfFQCdDM4iBMtfX%2BS-r9qgg%40mail.gmail.com
> <https://groups.google.com/d/msgid/golang-nuts/CAP1AJ8fqT0yxd2g8gctPA%2B6Ei-fKfFQCdDM4iBMtfX%2BS-r9qgg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAJhgacgUqYoJ%2Bo2fxjg_%3DUOiBgi%3DuuTuRo4qJeCN4CTim_F7eA%40mail.gmail.com.

Reply via email to