Context
를 넘겨주는 개념이다.TimeOut
, DeadLine
, Channel
을 통한 실행을 멈추도록 하는 것 등이 있다.Production Level
에서는 적절한 TimeOut
을 설정해 주는 것이 좋다.TimeOut
이나 DeadLine
Context가 매우 쉽게 예방을 할 수 있다.context package는 context 생성을 위한 다양한 함수를 제공한다.
context.Background() ctx Context => create context
highest level ( root of all derived context )
위 함수를 실행을 하면 비어있는 context 값을 얻을 수 있다. 또한 이 것을 사용하여 다른 context도 얻을 수 있다.
ctx, cancel := context.Background()