Re: [go-nuts] Returning a pointer or value struct.

2024-10-31 Thread Tushar Rawat
Got it. I've read both the *references* shared, it seems these rules can be used to understand if we should pass the value or pointer to a *function argument*. But, Can we really say that, the same rules apply for the return types as well ? I want to make idiomatic decision when to return a st

Re: [go-nuts] Returning a pointer or value struct.

2024-10-31 Thread Ian Lance Taylor
On Thu, Oct 31, 2024 at 6:24 AM Tushar Rawat wrote: > > I have seen few places where functions are returning struct as a value (for > instance time package, time is always returned as a value) and however at > some places folks prefer to return the pointers to struct instead of the copy. > > Whi

[go-nuts] Re: Check Channel is active or not while Writing as writer Go routine

2024-10-31 Thread 'Aniket Pandey' via golang-nuts
Hi All , while performing trial and error i just implemented an idea of not closing the channel in my go-lang code , due to which my server memory was going high , sharing it just FYI On Thursday 31 October 2024 at 11:27:09 UTC+5:30 Nico Braun wrote: > On Tuesday 29 October 2024 at 11:31:19 U

Re: [go-nuts] Re: Check Channel is active or not while Writing as writer Go routine

2024-10-31 Thread Nico Braun
I think not closing the channel has the side effect, of making it easier to leak goroutines. If your memory is growing, its likely that there is still a receiver who didn't realize there is nothing more to receive. That is one thing closing a channel can do and oftentimes does, i.e. when ranging

Re: [go-nuts] Re: Check Channel is active or not while Writing as writer Go routine

2024-10-31 Thread Ian Lance Taylor
On Thu, Oct 31, 2024 at 5:29 AM 'Aniket Pandey' via golang-nuts wrote: > > while performing trial and error i just implemented an idea of not closing > the channel in my go-lang code , due to which my server memory was going > high , sharing it just FYI I don't know what happened in your progr

[go-nuts] Returning a pointer or value struct.

2024-10-31 Thread Tushar Rawat
I have seen few places where functions are returning struct as a value (for instance time package, time is always returned as a value) and however at some places folks prefer to return the pointers to struct instead of the copy. Which one should be idiomatic approach, and when should we prefer