The Go CDK stores a Context in a struct while performing I/O: https://pkg.go.dev/gocloud.dev/blob#Bucket.NewWriter
It could be argued that this is done for compatibility with the io.Reader and io.Writer interfaces. However, I think this pattern, used sparingly, is suitable for API interactions where multiple method calls are required for a single conceptual task. -Ross On Tuesday, January 12, 2021 at 9:29:39 AM UTC-8 Jean de Klerk wrote: > Er, lifetime of the struct * > > On Tue, Jan 12, 2021 at 8:11 AM Jean de Klerk <dek...@google.com> wrote: > >> Hi all, >> >> I'm looking into how contexts are used, and wondering: does anybody know >> of an idiomatic use of context on a struct for the sake of a one-shot? >> >> (a one-shot being some struct that gets used once, like an RPC or http >> request) >> >> For example, http.Request has a context on its struct. But, I think the >> context exists there for backwards compatibility reasons. >> >> I'm looking for a struct that has context on it specifically because the >> context is scoped to the lifetime of the request. >> >> Thanks! >> Jean >> > -- 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/0b8690f0-0d73-460c-b944-4b2fe2e6c49dn%40googlegroups.com.