A
A
Adatan2019-12-08 19:49:26
go
Adatan, 2019-12-08 19:49:26

How to organize a cyclic event in Golang?

Here is an example code in Python

async def fff():
    count = 0
    while True:
        print(count)
        count += 1
        await asyncio.sleep(86400)
e>
How can I do something similar in Golang? Or something similar in principle of work? Someone told me about select...
You need to execute one event every 24 hours. Preferably with an example.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Shitskov, 2019-12-08
@Zarom

An example and a question are completely different. The above example is excellent, line for line, to go to Go.

func fff() {
    count := 0
    for {
        print(count)
        count += 1
    } 
}

If you need to implement exactly the scheduler a la cron, and in go itself - https://github.com/jasonlvhit/gocron/blob/master/R...

A
Alexander Pavlyuk, 2019-12-08
@pav5000

The above Python code executes an event more than once every 24 hours.
If you need once every 24 hours, you should study the tickers. https://gobyexample.com/tickers

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question