Re: [go-nuts] Adding context.Context as first parameter in every function

2024-03-03 Thread 'Yash Bansal' via golang-nuts
@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 li

Re: [go-nuts] Adding context.Context as first parameter in every function

2024-03-01 Thread Sam Vilain
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 imple

[go-nuts] Adding context.Context as first parameter in every function

2024-03-01 Thread 'Yash Bansal' via golang-nuts
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