# Context Package (Go) > context.Context, cancellation, timeouts, deadlines, values, WithCancel, WithTimeout - 20 interview questions - Mid-Level - [Interview Questions: Go](https://sharpskill.dev/en/technologies/go/interview-questions.md) ## 1. What is the main role of the context package in Go? **Answer** The context package allows managing timeouts, cancellations and deadlines consistently across the entire call chain. This prevents zombie goroutines that continue running when their result is no longer needed. Always pass the context as the first parameter and regularly check Done() in long operations to respect cancellations. ## 2. Which function creates an empty context without deadline or cancellation? **Answer** context.Background() returns an empty, non-cancellable context without deadline or values. It serves as a starting point for creating derived contexts and is typically used in main, initialization or tests. Never use nil as a context as it causes panics when accessing methods. ## 3. What is the difference between context.Background() and context.TODO()? **Answer** context.TODO() serves as a placeholder when the appropriate context is not yet clear or available during development. context.Background() is used for real entry points like main or HTTP handlers. Both are functionally identical but TODO() documents a temporary intention that should be replaced later. ## 17 more questions available - How to create a context that can be manually cancelled? - Which channel allows detecting the cancellation of a context? Sign up for free: https://sharpskill.dev/en/login ## Other Go interview topics - [Go Basics](https://sharpskill.dev/en/technologies/go/interview-questions/go-basics.md): 25 questions, Junior - [Go Data Structures](https://sharpskill.dev/en/technologies/go/interview-questions/go-data-structures.md): 20 questions, Junior - [Go Interfaces](https://sharpskill.dev/en/technologies/go/interview-questions/go-interfaces.md): 18 questions, Junior - [Error Handling](https://sharpskill.dev/en/technologies/go/interview-questions/error-handling.md): 20 questions, Junior - [Goroutines Basics](https://sharpskill.dev/en/technologies/go/interview-questions/goroutines-basics.md): 20 questions, Junior - [Channels](https://sharpskill.dev/en/technologies/go/interview-questions/channels.md): 22 questions, Junior - [Go Modules](https://sharpskill.dev/en/technologies/go/interview-questions/go-modules.md): 18 questions, Mid-Level - [HTTP Server](https://sharpskill.dev/en/technologies/go/interview-questions/http-server.md): 24 questions, Mid-Level - [HTTP Client](https://sharpskill.dev/en/technologies/go/interview-questions/http-client.md): 18 questions, Mid-Level - [JSON Encoding](https://sharpskill.dev/en/technologies/go/interview-questions/json-encoding.md): 20 questions, Mid-Level - [Database/SQL](https://sharpskill.dev/en/technologies/go/interview-questions/database-sql.md): 22 questions, Mid-Level - [Testing](https://sharpskill.dev/en/technologies/go/interview-questions/testing.md): 22 questions, Mid-Level - [Concurrency Patterns](https://sharpskill.dev/en/technologies/go/interview-questions/concurrency-patterns.md): 24 questions, Mid-Level - [Sync Primitives](https://sharpskill.dev/en/technologies/go/interview-questions/sync-primitives.md): 22 questions, Mid-Level - [Go Web Frameworks](https://sharpskill.dev/en/technologies/go/interview-questions/go-web-frameworks.md): 20 questions, Mid-Level - [REST API Design](https://sharpskill.dev/en/technologies/go/interview-questions/rest-api-design.md): 20 questions, Mid-Level - [gRPC](https://sharpskill.dev/en/technologies/go/interview-questions/grpc.md): 22 questions, Mid-Level - [Reflection](https://sharpskill.dev/en/technologies/go/interview-questions/reflection.md): 20 questions, Senior - [Memory Management](https://sharpskill.dev/en/technologies/go/interview-questions/memory-management.md): 24 questions, Senior - [Performance Optimization](https://sharpskill.dev/en/technologies/go/interview-questions/performance-optimization.md): 22 questions, Senior - [Generics](https://sharpskill.dev/en/technologies/go/interview-questions/generics.md): 20 questions, Senior - [Go Design Patterns](https://sharpskill.dev/en/technologies/go/interview-questions/design-patterns.md): 24 questions, Senior - [Microservices](https://sharpskill.dev/en/technologies/go/interview-questions/microservices.md): 24 questions, Senior - [Security & Authentication](https://sharpskill.dev/en/technologies/go/interview-questions/security-authentication.md): 24 questions, Senior - [Docker & Containerization](https://sharpskill.dev/en/technologies/go/interview-questions/docker-containerization.md): 20 questions, Senior - [Kubernetes Basics](https://sharpskill.dev/en/technologies/go/interview-questions/kubernetes-basics.md): 22 questions, Senior - [Advanced Go](https://sharpskill.dev/en/technologies/go/interview-questions/advanced-go.md): 20 questions, Senior - [CLI Development](https://sharpskill.dev/en/technologies/go/interview-questions/cli-development.md): 20 questions, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/en/technologies/go/interview-questions/context-package