Skip to content

context-stored-in-struct

Default severity: warning

Contexts carry request-scoped cancellation, deadlines, and values. Keeping one in a struct obscures its lifetime and can accidentally reuse stale request state. Pass the context explicitly to each operation that needs it.

type Service struct { ctx context.Context }
func (service *Service) Run(ctx context.Context) error