{"id":18728916,"url":"https://github.com/uberswe/interval","last_synced_at":"2025-11-12T05:30:22.725Z","repository":{"id":57565514,"uuid":"337566478","full_name":"uberswe/interval","owner":"uberswe","description":"Interval is a Go package which uses Golangs time.Duration to perform different functions. For example calling another function at set intervals","archived":false,"fork":false,"pushed_at":"2021-02-13T13:42:14.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-28T14:28:22.733Z","etag":null,"topics":["golang","interval","recurring"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uberswe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-09T23:38:40.000Z","updated_at":"2022-01-06T16:23:46.000Z","dependencies_parsed_at":"2022-09-03T11:20:56.587Z","dependency_job_id":null,"html_url":"https://github.com/uberswe/interval","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uberswe%2Finterval","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uberswe%2Finterval/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uberswe%2Finterval/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uberswe%2Finterval/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uberswe","download_url":"https://codeload.github.com/uberswe/interval/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239599040,"owners_count":19665911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","interval","recurring"],"created_at":"2024-11-07T14:24:47.495Z","updated_at":"2025-11-12T05:30:22.676Z","avatar_url":"https://github.com/uberswe.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# interval\n\nInterval is a package which uses Golangs time.Duration to perform different functions.\n\nWith the DoEvery functions it is possible to call a function in Golang every x seconds. Depending on the function you can do this in a blocking or asyncronous way.\n\nIt is also possible to check if enough time has passed between two times. Such as checking if something has executed 7 days before today for example.\n\nTo call a function repeatedly at a set interval simply do this\n\n```go\nfunc main() {\n\tlambda := func(interval time.Duration, time time.Time, extra interface{}) {\n\t\tlog.Printf(\"do function called %s at %s\\n\", interval.String(), time.String())\n\t}\n\terr := interval.DoEvery(\"1s\", nil, lambda, -1)\n\tif err != nil {\n\t\tlog.Panicf(\"Error: %v\", err)\n\t}\n\tlog.Println(\"This is never called because DoEvery is blocking\")\n}\n```\n\nBy passing -1 to interval.DoEvery the function will run in an infinite loop.\n\nYou can use DoEveryAsync to call a function repeatedly in a non-blocking way like so\n\n```go\nfunc main() {\n\tlambda := func(interval time.Duration, time time.Time, extra interface{}) {\n\t\tlog.Printf(\"do function called %s at %s\\n\", interval.String(), time.String())\n\t}\n\texit, err := interval.DoEveryAsync(\"1s\", nil, lambda, -1)\n\tif err != nil {\n\t\tlog.Panicf(\"Error: %v\", err)\n\t}\n\tlog.Println(\"This is called because DoEveryAsync is non-blocking\")\n\t// sleep for 10 seconds\n\ttime.Sleep(time.Second * 10)\n\t// exit the async\n\texit \u003c- 1\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuberswe%2Finterval","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuberswe%2Finterval","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuberswe%2Finterval/lists"}