@axel Most of the functions I have (except the utility ones) will be 
needing the context parameter, that's why I thought of adding context to 
every function, and just using auto-refactoring to remove context from the 
functions which doesn't use it.

@Sam Thanks for providing me with your repo link. Will go through it for 
sure. Sadly, I have started manually editing every function to add the 
parameter now. Let's hope the go-devs address my problem.


On Friday, March 1, 2024 at 11:07:34 PM UTC+5:30 Sam Vilain wrote:

> Hi Yash, unfortunately that's the only approach at the moment.
>
> Your request is very apropos of my thread, "Could we trade all the `ctx 
> context.Context` arguments for one pointer in `g`?".  This is the exact use 
> case I have in mind.  I believe it should be possible, and even a fairly 
> naïve implementation should not slow down code that does not use the 
> context variables at all.
>
> I have a proposal in draft at: https://github.com/samv/go-context-proposal
>
> Cheers,
> Sam
>
>
> On 3/1/24 12:40 AM, 'Yash Bansal' via golang-nuts wrote:
>
> Hello, 
>
> I recently started writing code in Golang and wasn't aware that unlike 
> Java, we can't use ThreadLocals to propagate a context across the code. 
> It's mandatory to explicitly pass a context. I have already written a 
> service which is live in production now, however for monitoring and other 
> reasons, I need to pass the context argument to every function. 
>
> *ASK *
> Is there a tool or library which can help me do the same, instead of me 
> going to every function and it's caller and adding the context field?
>
> I have been following this thread - 
> https://groups.google.com/g/golang-nuts/c/ti8M-fuu6RE/m/8w3LA1dXAwAJ
> But looks like people in this thread have abandoned the idea of making a 
> library like this.
>
> Any leads would be appreciated. 
>
>
>
>
> *::DISCLAIMER:: 
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>  
> The contents of this e-mail and any attachments are confidential and 
> intended for the named recipient(s) only.E-mail transmission is not 
> guaranteed to be secure or error-free as information could be intercepted, 
> corrupted,lost, destroyed, arrive late or incomplete, or may contain 
> viruses in transmission. The e mail and its contents(with or without 
> referred errors) shall therefore not attach any liability on the originator 
> or redBus.com. Views or opinions, if any, presented in this email are 
> solely those of the author and may not necessarily reflect the views or 
> opinions of redBus.com. Any form of reproduction, dissemination, copying, 
> disclosure, modification,distribution and / or publication of this message 
> without the prior written consent of authorized representative of redbus. 
> <http://redbus.in/>com is strictly prohibited. If you have received this 
> email in error please delete it and notify the sender immediately.Before 
> opening any email and/or attachments, please check them for viruses and 
> other defects.* -- 
>
> 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...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/58b07900-05cf-4550-b069-96c6d4cc3614n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/golang-nuts/58b07900-05cf-4550-b069-96c6d4cc3614n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> -- 
> Sam
>
>
-- 
*::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachments are confidential and 
intended for the named recipient(s) only.E-mail transmission is not 
guaranteed to be secure or error-free as information could be intercepted, 
corrupted,lost, destroyed, arrive late or incomplete, or may contain 
viruses in transmission. The e mail and its contents(with or without 
referred errors) shall therefore not attach any liability on the originator 
or redBus.com. Views or opinions, if any, presented in this email are 
solely those of the author and may not necessarily reflect the views or 
opinions of redBus.com. Any form of reproduction, dissemination, copying, 
disclosure, modification,distribution and / or publication of this message 
without the prior written consent of authorized representative of redbus. 
<http://redbus.in/>com is strictly prohibited. If you have received this 
email in error please delete it and notify the sender immediately.Before 
opening any email and/or attachments, please check them for viruses and 
other defects.*

-- 
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/c37b2bf0-a568-4187-9b31-9cffd58b90d1n%40googlegroups.com.

Reply via email to