Skip to content

fix: remove context propogation as pointer#37

Merged
GoshaDo merged 1 commit intomainfrom
fix-context-idiomatic
Jan 11, 2025
Merged

fix: remove context propogation as pointer#37
GoshaDo merged 1 commit intomainfrom
fix-context-idiomatic

Conversation

@GoshaDo
Copy link
Contributor

@GoshaDo GoshaDo commented Jan 9, 2025

Pull Request

Description

context.Context is immutable:
The context.Context type and its implementations (e.g., context.Background(), context.WithCancel, context.WithTimeout) are immutable. Each operation that modifies a context (e.g., adding a deadline or attaching values) returns a new context.
This immutability means you can safely pass a context.Context by value without worrying about unintended side effects.

Interface Semantics:
context.Context is an interface, not a struct. When you pass it, you are effectively passing a pointer to the underlying implementation, even though it appears to be passed by value. This makes passing it by pointer unnecessary.

Checklist

Before submitting this pull request, please ensure that you have completed the following tasks:

@GoshaDo GoshaDo merged commit 075cbf2 into main Jan 11, 2025
8 checks passed
@GoshaDo GoshaDo deleted the fix-context-idiomatic branch January 11, 2025 17:58
This was referenced Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants