A
A
Artem Rogozin2019-12-02 15:43:01
go
Artem Rogozin, 2019-12-02 15:43:01

How to exit a function after a certain period of time?

I am writing a chat bot for VK. The main handler function, launched in a separate goroutine, reacts to events, for example, if a new message has arrived. I need to exit this function to release resources if no events occur within 24 hours. How to implement it in Go?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-12-02
@dmtrrr

https://golang.org/pkg/context/#example_WithTimeout

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question