Skip to content

Commit

Permalink
add explicit initialization of fields of structures in internal/xcontext
Browse files Browse the repository at this point in the history
  • Loading branch information
kozyrev-m committed Apr 15, 2024
1 parent bf69614 commit 14511ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/xcontext/context_with_cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
func WithCancel(ctx context.Context) (context.Context, context.CancelFunc) {
childCtx := &cancelCtx{
parentCtx: ctx,
ctx: nil,
ctxCancel: nil,
m: sync.Mutex{},
err: nil,
}
childCtx.ctx, childCtx.ctxCancel = context.WithCancel(ctx)

Expand Down
4 changes: 4 additions & 0 deletions internal/xcontext/context_with_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import (
func WithTimeout(ctx context.Context, t time.Duration) (context.Context, context.CancelFunc) {
childCtx := &timeoutCtx{
parentCtx: ctx,
ctx: nil,
ctxCancel: nil,
from: stack.Record(1),
m: sync.Mutex{},
err: nil,
}
childCtx.ctx, childCtx.ctxCancel = context.WithTimeout(ctx, t)

Expand Down

0 comments on commit 14511ab

Please sign in to comment.