gocron
Copilot instructions7.2k starsChanged 4 months agoMITView on GitHub
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. Example validation script:
- Installs packages
We split this copilot-instructions.md into the rules it gives an agent
16 rules. About 0 are common, 3 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 3
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does …
- Very specific: line 17
Run all tests: make test -- takes 50 seconds.
- Very specific: line 18
Run CI tests: make test_ci -- takes 50 seconds.
- Very specific: line 19
Run with coverage: make test_coverage -- takes 50 seconds.
- Very specific: line 20
Run specific tests: go test -v -race -count=1 ./...
- Very specific: line 30
ALWAYS run make test before submitting changes.
- Very specific: line 31
ALWAYS run make fmt to ensure proper formatting.
- Very specific: line 32
ALWAYS run make mocks if you change interface definitions.
- Very specific: line 33
ALWAYS verify examples still work by running them: cd examples/elector && go run main.go
- Very specific: line 37
Basic Scheduler Creation: Verify you can create a scheduler with gocron.NewScheduler()
- Very specific: line 38
Job Creation: Verify you can create jobs with various JobDefinition types
- Distinctive: line 39
Scheduler Lifecycle: Verify Start() and Shutdown() work correctly
- Very specific: line 40
Example Validation: Run examples in examples/ directory to ensure functionality
- Distinctive: line 117
No application to build - this is a library
- Very specific: line 128
PATH issues: Ensure $(go env GOPATH)/bin is in PATH
- Very specific: line 129
Import errors in examples: Run go mod tidy to resolve dependencies
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
gocron: Go Job Scheduling Library
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
Working Effectively
Bootstrap and Build Commands
- Install dependencies:
go mod tidy - Build the library:
go build -v ./... - Install required tools:
go install go.uber.org/mock/mockgen@latestexport PATH=$PATH:$(go env GOPATH)/bin(add to shell profile)
- Generate mocks:
make mocks - Format code:
make fmt
Testing Commands
- Run all tests:
make test-- takes 50 seconds. NEVER CANCEL. Set timeout to 90+ seconds. - Run CI tests:
make test_ci-- takes 50 seconds. NEVER CANCEL. Set timeout to 90+ seconds. - Run with coverage:
make test_coverage-- takes 50 seconds. NEVER CANCEL. Set timeout to 90+ seconds. - Run specific tests:
go test -v -race -count=1 ./...
Linting Commands
- Format verification:
grep "^func [a-zA-Z]" example_test.go | sort -c - Full linting:
make lint-- MAY FAIL due to golangci-lint config compatibility issues. This is a known issue. - Alternative basic linting:
go vet ./...andgofmt -d .
Validation
Required Validation Steps
- ALWAYS run
make testbefore submitting changes. Tests must pass. - ALWAYS run
make fmtto ensure proper formatting. - ALWAYS run
make mocksif you change interface definitions. - ALWAYS verify examples still work by running them:
cd examples/elector && go run main.go
Manual Testing Scenarios
Since this is a library, not an application, testing involves:
- Basic Scheduler Creation: Verify you can create a scheduler with
gocron.NewScheduler() - Job Creation: Verify you can create jobs with various
JobDefinitiontypes - Scheduler Lifecycle: Verify Start() and Shutdown() work correctly
- Example Validation: Run examples in
examples/directory to ensure functionality
Example validation script:
package main
import (
"fmt"
"time"
"github.com/go-co-op/gocron/v2"
)
func main() {
s, err := gocron.NewScheduler()
if err != nil { panic(err) }
j, err := s.NewJob(
gocron.DurationJob(2*time.Second),
gocron.NewTask(func() { fmt.Println("Working!") }),
)
if err != nil { panic(err) }
fmt.Printf("Job ID: %s\n", j.ID())
s.Start()
time.Sleep(6 * time.Second)
s.Shutdown()
}CI Requirements
The CI will fail if:
- Tests don't pass (
make test_ci) - Function order in
example_test.gois incorrect - golangci-lint finds issues (though config compatibility varies)
Common Tasks
Repository Structure
.
├── README.md # Main documentation
├── CONTRIBUTING.md # Contribution guidelines
├── SECURITY.md # Security policy
├── Makefile # Build automation
├── go.mod # Go module definition
├── .github/ # GitHub workflows and configs
├── .golangci.yaml # Linting configuration
├── examples/ # Usage examples
│ └── elector/ # Distributed elector example
├── mocks/ # Generated mock files
├── *.go # Library source files
└── *_test.go # Test filesKey Source Files
scheduler.go- Main scheduler implementationjob.go- Job definitions and scheduling logicexecutor.go- Job execution enginelogger.go- Logging interfaces and implementationsdistributed.go- Distributed scheduling supportmonitor.go- Job monitoring interfacesutil.go- Utility functionserrors.go- Error definitions
Dependencies and Versions
- Requires Go 1.23.0+ (CI matrix pins to
stable/oldstable— see.github/workflows/go_test.yml) - Key dependencies automatically managed via
go mod:github.com/google/uuid- UUID generationgithub.com/jonboulle/clockwork- Time mocking for testsgithub.com/robfig/cron/v3- Cron expression parsinggithub.com/stretchr/testify- Testing utilitiesgo.uber.org/goleak- Goroutine leak detection
Testing Patterns
- Uses table-driven tests following Go best practices
- Extensive use of goroutine leak detection (may be skipped in CI via TEST_ENV)
- Mock-based testing for interfaces
- Race condition detection enabled (
-raceflag) - 93.8% test coverage expected
Build and Release
- No application to build - this is a library
- Version managed via Git tags (v2.x.x)
- Distribution via Go module system
- CI tests on Go
stableandoldstable(see.github/workflows/go_test.yml)
Troubleshooting
Common Issues
- mockgen not found: Install with
go install go.uber.org/mock/mockgen@latest - golangci-lint config errors: Known compatibility issue - use
go vetinstead - Test timeouts: Tests can take 50+ seconds, always set adequate timeouts
- PATH issues: Ensure
$(go env GOPATH)/binis in PATH - Import errors in examples: Run
go mod tidyto resolve dependencies
Expected Timings
make test: ~50 secondsmake test_coverage: ~50 secondsmake test_ci: ~50 secondsgo build: ~5 secondsmake mocks: ~2 secondsmake fmt: <1 second
Known Limitations
- golangci-lint configuration may have compatibility issues with certain versions
- Some tests are skipped in CI environments (controlled by TEST_ENV variable)
- Examples directory has no tests but should be manually validated
Trending
Quiet since September.about the whole repository
Who's talking about go-co-op/gocron
- Stack Overflow“Golang: Implementing a cron / executing tasks at a specific time”Stack Overflow · Feb 11, 2016 · 31 votes
- runatlantis/atlantis“[Refactor] Rewrite the `ExecutorService` to a cron supported scheduler”GitHub · Oct 20, 2025 · 13 reactions
- go-gitea/gitea“Replace gogs/cron with go-co-op/gocron”GitHub · Jul 19, 2023 · 5 reactions
- Stack Overflow“Is there a way to do repetitive tasks at intervals?”Stack Overflow · May 2, 2022 · 5 votes
- go-kratos/kratos“如何通过依赖注入 wire 后台作业?”GitHub · May 17, 2021 · 4 reactions
The biggest 5 of 55 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 55
Talked about on GitHub and Stack Overflow (55 times).
On GitHub · 50
- Oct 20, 2025[Refactor] Rewrite the `ExecutorService` to a cron supported scheduler — runatlantis/atlantis13 reactions
- Jul 19, 2023Replace gogs/cron with go-co-op/gocron — go-gitea/gitea5 reactions · 2 comments
- May 17, 2021如何通过依赖注入 wire 后台作业? — go-kratos/kratos4 reactions · 8 comments
- Mar 31, 2021[Feature] Cron Scheduler for Nakama — heroiclabs/nakama4 reactions
- May 4, 2026Dependency Dashboard — go-gitea/gitea3 reactions
45 more on GitHub
- Jun 25, 2021proposal: cmd/go: add SPDX license list to go.mod file — golang/go3 reactions · 13 comments
- Apr 21, 2026chore(deps): update module github.com/go-co-op/gocron/v2 to v2.21.1 — LumeWeb/portal2 reactions
- Apr 20, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260420205010-8e553c021ccd — LumeWeb/portal2 reactions
- Nov 21, 2025chore(main): release 2.0.0 — distr-sh/distr2 reactions · 1 comment
- Nov 5, 2025bigtable: error logs writing metrics after upgrade from v1.39.0 to v1.40.1 — googleapis/google-cloud-go2 reactions · 10 comments
- Oct 30, 2023Fixing race condition in concurrent writing of 'cachedSessions' map. — uadmin/uadmin2 reactions · 1 comment
- Aug 3, 2026chore(deps): migrate job scheduler from robfig/cron to gocron/v2 — jabrown93/AURA1 reaction
- Jul 17, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260717182408-cc444c2a6f2c — LumeWeb/portal1 reaction · 1 comment
- Jul 11, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260710211738-6b80c414e96f — LumeWeb/portal1 reaction · 1 comment
- Jul 9, 2026chore(deps): update module github.com/go-co-op/gocron/v2 to v2.22.0 — LumeWeb/portal1 reaction · 1 comment
- Jul 9, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260709183641-10cdd5e5558f — LumeWeb/portal1 reaction · 1 comment
- Jul 9, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260708234909-c4697d43e545 — LumeWeb/portal1 reaction · 1 comment
- Jul 8, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260708211158-fe80573fdf9e — LumeWeb/portal1 reaction · 1 comment
- Jul 8, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260708173245-c3fa241ceee5 — LumeWeb/portal1 reaction · 1 comment
- Jul 7, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260707215852-f7abd19f08ff — LumeWeb/portal1 reaction · 1 comment
- Jul 7, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260707142944-b8706290bc4e — LumeWeb/portal1 reaction · 1 comment
- Jul 6, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260706212300-42bd428e24bb — LumeWeb/portal1 reaction · 1 comment
- Jun 30, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260630210515-593e68b76d30 — LumeWeb/portal1 reaction · 1 comment
- Jun 30, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260630023957-a716034738e5 — LumeWeb/portal1 reaction · 1 comment
- Jun 29, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260629162726-89341b085fbc — LumeWeb/portal1 reaction · 1 comment
- Jun 5, 2026chore(snmp-discovery,network-discovery): bump diode-sdk-go to v1.9.0 + other deps — netboxlabs/orb-discovery1 reaction · 6 comments
- May 12, 2026chore(deps): update module github.com/go-co-op/gocron/v2 to v2.21.2 — LumeWeb/portal1 reaction
- May 12, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260512155149-629cfc547b82 — LumeWeb/portal1 reaction
- Apr 27, 2026Actions withScheduleInEventPayload PANIC — go-gitea/gitea1 reaction · 2 comments
- Apr 15, 2026chore(deps): update module github.com/go-co-op/gocron/v2 to v2.21.0 — LumeWeb/portal1 reaction
- Apr 10, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260413214425-54f6bd850169 — LumeWeb/portal1 reaction
- Apr 10, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260409220654-2e69a262f258 — LumeWeb/portal1 reaction
- Apr 9, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260409020655-1e25a3b037b1 — LumeWeb/portal1 reaction
- Apr 6, 2026chore(deps): update module github.com/go-co-op/gocron/v2 to v2.20.0 — LumeWeb/portal1 reaction
- Apr 1, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260402155826-89567e91444e — LumeWeb/portal1 reaction
- Mar 20, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260320165816-5b307f56dd52 - autoclosed — LumeWeb/portal1 reaction
- Mar 20, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260320165816-5b307f56dd52 — LumeWeb/portal1 reaction
- Mar 10, 2026chore(deps): update module github.com/go-co-op/gocron/mocks/v2 to v2.0.0-20260310150556-102b2b2c8e41 — LumeWeb/portal1 reaction
- Feb 25, 2026chore(deps): update module github.com/go-co-op/gocron/v2 to v2.19.1 — LumeWeb/portal1 reaction
- Nov 1, 2025General issue https://go.uber.org/atomic?go-get=1 getting BAD GATEWAY - Please help — uber-go/atomic1 reaction · 1 comment
- Feb 23, 2024Auto update failing for gitea — termux/termux-packages1 reaction
- Aug 5, 2022Error response from Panel: ValidationException: The data.0.ip must be a valid IP address. (HTTP/422) — pterodactyl/panel1 reaction · 1 comment
- Oct 14, 2021[Bug] v1.2.27-28 在未安装go环境的windows上读取时区出错 — axiaoxin-com/investool1 reaction · 4 comments
- Sep 12, 2026Job Scheduler — go-hypercube/go-hypercube0 reactions
- Sep 6, 2026Dependency Dashboard — madsbacha/ts3-online0 reactions
- Aug 29, 2026Dependency Dashboard — nrosier/pgbackweb0 reactions
- Aug 9, 2026Dependency Dashboard — lila-network/humble-bot0 reactions
- Aug 5, 2026Agent crashing after about 30 minutes with *PANIC* — open-uem/openuem-worker0 reactions
- Jul 18, 2026Dependency Dashboard — das-kaesebrot/feedrrr0 reactions
- Apr 1, 2026[dong] Investigate and apply gocron for scheduling task — mezonai/mmn-tx-explorer0 reactions · 1 comment
On Stack Overflow · 5
- Feb 11, 2016Golang: Implementing a cron / executing tasks at a specific time31 votes
- May 2, 2022Is there a way to do repetitive tasks at intervals?5 votes
- Jul 16, 2024How to recover task function in gocron after server fails and reboots1 vote
- Mar 8, 2023Standard library implementation (testable) of gocron function1 vote · 1 answer
- Mar 26, 2025increasing number of goroutines when using go-co-op/gocron0 votes · 1 answer
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

