{"id":27880853,"url":"https://github.com/atomicgo/schedule","last_synced_at":"2025-05-05T04:38:47.007Z","repository":{"id":60787906,"uuid":"545530609","full_name":"atomicgo/schedule","owner":"atomicgo","description":"⏰ Easily schedule non-blocking tasks in Go. Supports durations, specific times and intervals.","archived":false,"fork":false,"pushed_at":"2025-02-27T12:18:39.000Z","size":47,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-27T17:20:48.578Z","etag":null,"topics":["atomicgo","go","golang","golang-library","hacktoberfest","schedule","scheduler","ticker","time","timer"],"latest_commit_sha":null,"homepage":"https://atomicgo.dev","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/atomicgo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["MarvinJWendt"]}},"created_at":"2022-10-04T14:31:31.000Z","updated_at":"2025-02-27T08:58:51.000Z","dependencies_parsed_at":"2024-06-19T04:09:12.038Z","dependency_job_id":"71db7b6d-1b42-4e7d-aa66-86d19b01f288","html_url":"https://github.com/atomicgo/schedule","commit_stats":{"total_commits":43,"total_committers":1,"mean_commits":43.0,"dds":0.0,"last_synced_commit":"04edce3656d8f686fcd5711c95e2fcb9ea88098d"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":"atomicgo/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fschedule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fschedule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fschedule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fschedule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicgo","download_url":"https://codeload.github.com/atomicgo/schedule/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252442480,"owners_count":21748448,"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":["atomicgo","go","golang","golang-library","hacktoberfest","schedule","scheduler","ticker","time","timer"],"created_at":"2025-05-05T04:38:42.556Z","updated_at":"2025-05-05T04:38:46.998Z","avatar_url":"https://github.com/atomicgo.png","language":"Go","funding_links":["https://github.com/sponsors/MarvinJWendt"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eAtomicGo | schedule\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fatomicgo.dev%2Fapi%2Fshields%2Fschedule\u0026style=flat-square\" alt=\"Downloads\"\u003e\n\n\u003ca href=\"https://github.com/atomicgo/schedule/releases\"\u003e\n\u003cimg src=\"https://img.shields.io/github/v/release/atomicgo/schedule?style=flat-square\" alt=\"Latest Release\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/atomicgo/schedule\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/atomicgo/schedule/go.yml?style=flat-square\" alt=\"Tests\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/atomicgo/schedule\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/codecov/c/gh/atomicgo/schedule?color=magenta\u0026logo=codecov\u0026style=flat-square\" alt=\"Coverage\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/atomicgo/schedule\"\u003e\n\u003c!-- unittestcount:start --\u003e\u003cimg src=\"https://img.shields.io/badge/Unit_Tests-0-magenta?style=flat-square\" alt=\"Unit test count\"\u003e\u003c!-- unittestcount:end --\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://opensource.org/licenses/MIT\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square\" alt=\"License: MIT\"\u003e\n\u003c/a\u003e\n  \n\u003ca href=\"https://goreportcard.com/report/github.com/atomicgo/schedule\" target=\"_blank\"\u003e\n\u003cimg src=\"https://goreportcard.com/badge/github.com/atomicgo/schedule?style=flat-square\" alt=\"Go report\"\u003e\n\u003c/a\u003e   \n\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n\u003cstrong\u003e\u003ca href=\"https://pkg.go.dev/atomicgo.dev/schedule#section-documentation\" target=\"_blank\"\u003eDocumentation\u003c/a\u003e\u003c/strong\u003e\n|\n\u003cstrong\u003e\u003ca href=\"https://github.com/atomicgo/atomicgo/blob/main/CONTRIBUTING.md\" target=\"_blank\"\u003eContributing\u003c/a\u003e\u003c/strong\u003e\n|\n\u003cstrong\u003e\u003ca href=\"https://github.com/atomicgo/atomicgo/blob/main/CODE_OF_CONDUCT.md\" target=\"_blank\"\u003eCode of Conduct\u003c/a\u003e\u003c/strong\u003e\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/atomicgo/atomicgo/main/assets/header.png\" alt=\"AtomicGo\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ctable\u003e\n\u003ctbody\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/p\u003e\n\u003ch3  align=\"center\"\u003e\u003cpre\u003ego get atomicgo.dev/schedule\u003c/pre\u003e\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n\u003ctable\u003e\n\u003ctbody\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/p\u003e\n\n\u003c!-- gomarkdoc:embed:start --\u003e\n\n\u003c!-- Code generated by gomarkdoc. DO NOT EDIT --\u003e\n\n# schedule\n\n```go\nimport \"atomicgo.dev/schedule\"\n```\n\nPackage schedule provides a simple scheduler for Go.\n\nIt can run a function at a given time, in a given duration, or repeatedly at a given interval.\n\n## Index\n\n- [type Task](\u003c#Task\u003e)\n  - [func After\\(duration time.Duration, task func\\(\\)\\) \\*Task](\u003c#After\u003e)\n  - [func At\\(t time.Time, task func\\(\\)\\) \\*Task](\u003c#At\u003e)\n  - [func Every\\(interval time.Duration, task func\\(\\) bool\\) \\*Task](\u003c#Every\u003e)\n  - [func \\(s \\*Task\\) ExecutesIn\\(\\) time.Duration](\u003c#Task.ExecutesIn\u003e)\n  - [func \\(s \\*Task\\) IsActive\\(\\) bool](\u003c#Task.IsActive\u003e)\n  - [func \\(s \\*Task\\) NextExecutionTime\\(\\) time.Time](\u003c#Task.NextExecutionTime\u003e)\n  - [func \\(s \\*Task\\) StartedAt\\(\\) time.Time](\u003c#Task.StartedAt\u003e)\n  - [func \\(s \\*Task\\) Stop\\(\\)](\u003c#Task.Stop\u003e)\n  - [func \\(s \\*Task\\) Wait\\(\\)](\u003c#Task.Wait\u003e)\n\n\n\u003ca name=\"Task\"\u003e\u003c/a\u003e\n## type [Task](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L6-L10\u003e)\n\nTask holds information about the running task and can be used to stop running tasks.\n\n```go\ntype Task struct {\n    // contains filtered or unexported fields\n}\n```\n\n\u003ca name=\"After\"\u003e\u003c/a\u003e\n### func [After](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L58\u003e)\n\n```go\nfunc After(duration time.Duration, task func()) *Task\n```\n\nAfter executes the task after the given duration. The function is non\\-blocking. If you want to wait for the task to be executed, use the Task.Wait method.\n\n\u003cdetails\u003e\u003csummary\u003eExample\u003c/summary\u003e\n\u003cp\u003e\n\n\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"atomicgo.dev/schedule\"\n)\n\nfunc main() {\n\ttask := schedule.After(5*time.Second, func() {\n\t\tfmt.Println(\"5 seconds are over!\")\n\t})\n\n\tfmt.Println(\"Some stuff happening...\")\n\n\ttask.Wait()\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003ca name=\"At\"\u003e\u003c/a\u003e\n### func [At](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L77\u003e)\n\n```go\nfunc At(t time.Time, task func()) *Task\n```\n\nAt executes the task at the given time. The function is non\\-blocking. If you want to wait for the task to be executed, use the Task.Wait method.\n\n\u003cdetails\u003e\u003csummary\u003eExample\u003c/summary\u003e\n\u003cp\u003e\n\n\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"atomicgo.dev/schedule\"\n)\n\nfunc main() {\n\ttask := schedule.At(time.Now().Add(5*time.Second), func() {\n\t\tfmt.Println(\"5 seconds are over!\")\n\t})\n\n\tfmt.Println(\"Some stuff happening...\")\n\n\ttask.Wait()\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003ca name=\"Every\"\u003e\u003c/a\u003e\n### func [Every](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L96\u003e)\n\n```go\nfunc Every(interval time.Duration, task func() bool) *Task\n```\n\nEvery executes the task in the given interval, as long as the task function returns true. The function is non\\-blocking. If you want to wait for the task to be executed, use the Task.Wait method.\n\n\u003cdetails\u003e\u003csummary\u003eExample\u003c/summary\u003e\n\u003cp\u003e\n\n\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"atomicgo.dev/schedule\"\n)\n\nfunc main() {\n\ttask := schedule.Every(time.Second, func() bool {\n\t\tfmt.Println(\"1 second is over!\")\n\n\t\treturn true // return false to stop the task\n\t})\n\n\tfmt.Println(\"Some stuff happening...\")\n\n\ttime.Sleep(10 * time.Second)\n\n\ttask.Stop()\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003ca name=\"Task.ExecutesIn\"\u003e\u003c/a\u003e\n### func \\(\\*Task\\) [ExecutesIn](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L31\u003e)\n\n```go\nfunc (s *Task) ExecutesIn() time.Duration\n```\n\nExecutesIn returns the duration until the next execution.\n\n\u003ca name=\"Task.IsActive\"\u003e\u003c/a\u003e\n### func \\(\\*Task\\) [IsActive](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L36\u003e)\n\n```go\nfunc (s *Task) IsActive() bool\n```\n\nIsActive returns true if the scheduler is active.\n\n\u003ca name=\"Task.NextExecutionTime\"\u003e\u003c/a\u003e\n### func \\(\\*Task\\) [NextExecutionTime](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L26\u003e)\n\n```go\nfunc (s *Task) NextExecutionTime() time.Time\n```\n\nNextExecutionTime returns the time when the next execution will happen.\n\n\u003ca name=\"Task.StartedAt\"\u003e\u003c/a\u003e\n### func \\(\\*Task\\) [StartedAt](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L21\u003e)\n\n```go\nfunc (s *Task) StartedAt() time.Time\n```\n\nStartedAt returns the time when the scheduler was started.\n\n\u003ca name=\"Task.Stop\"\u003e\u003c/a\u003e\n### func \\(\\*Task\\) [Stop](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L52\u003e)\n\n```go\nfunc (s *Task) Stop()\n```\n\nStop stops the scheduler.\n\n\u003ca name=\"Task.Wait\"\u003e\u003c/a\u003e\n### func \\(\\*Task\\) [Wait](\u003chttps://github.com/atomicgo/schedule/blob/main/schedule.go#L47\u003e)\n\n```go\nfunc (s *Task) Wait()\n```\n\nWait blocks until the scheduler is stopped. After and At will stop automatically after the task is executed.\n\nGenerated by [gomarkdoc](\u003chttps://github.com/princjef/gomarkdoc\u003e)\n\n\n\u003c!-- gomarkdoc:embed:end --\u003e\n\n---\n\n\u003e [AtomicGo.dev](https://atomicgo.dev) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e with ❤️ by [@MarvinJWendt](https://github.com/MarvinJWendt) |\n\u003e [MarvinJWendt.com](https://marvinjwendt.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicgo%2Fschedule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicgo%2Fschedule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicgo%2Fschedule/lists"}