The Context as "a bag of stuff" is attractive since it makes your code
easier to refactor (knock, knock) but gives me void* or as Jakob said
map[string]interface{} vibes.

I think I think it should be avoided but probably not unconditionally. I
guess there can be cases where it makes sense.


ons 8 feb. 2017 kl 13:02 skrev Jakob Borg <ja...@nym.se>:

> On 7 Feb 2017, at 03:57, Steven Roth <st...@rothskeller.net> wrote:
> > My question is whether putting the transaction in the context using
> context.WithValue is a reasonable and appropriate use of that mechanism.
> If not, why not?
>
> In my opinion, this is morally equivalent to a
>
>     func Something(params map[interface{}]interface{})
>
> which is a horrible API that no-one here would accept. If the function
> needs a sql.Tx that should be one of the parameters. That the function also
> takes a Context is beside the point.
>
> //jb
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to