agentleFS
go-co-opgo-co-op/gocron/.github/copilot-instructions.md

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
  1. Distinctive:

    Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does …

    line 3
  2. Very specific:

    Run all tests: make test -- takes 50 seconds.

    line 17
  3. Very specific:

    Run CI tests: make test_ci -- takes 50 seconds.

    line 18
  4. Very specific:

    Run with coverage: make test_coverage -- takes 50 seconds.

    line 19
  5. Very specific:

    Run specific tests: go test -v -race -count=1 ./...

    line 20
  6. Very specific:

    ALWAYS run make test before submitting changes.

    line 30
  7. Very specific:

    ALWAYS run make fmt to ensure proper formatting.

    line 31
  8. Very specific:

    ALWAYS run make mocks if you change interface definitions.

    line 32
  9. Very specific:

    ALWAYS verify examples still work by running them: cd examples/elector && go run main.go

    line 33
  10. Very specific:

    Basic Scheduler Creation: Verify you can create a scheduler with gocron.NewScheduler()

    line 37
  11. Very specific:

    Job Creation: Verify you can create jobs with various JobDefinition types

    line 38
  12. Distinctive:

    Scheduler Lifecycle: Verify Start() and Shutdown() work correctly

    line 39
  13. Very specific:

    Example Validation: Run examples in examples/ directory to ensure functionality

    line 40
  14. Distinctive:

    No application to build - this is a library

    line 117
  15. Very specific:

    PATH issues: Ensure $(go env GOPATH)/bin is in PATH

    line 128
  16. Very specific:

    Import errors in examples: Run go mod tidy to resolve dependencies

    line 129

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

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@latest
    • export 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 ./... and gofmt -d .

Validation

Required Validation Steps

  • ALWAYS run make test before submitting changes. Tests must pass.
  • ALWAYS run make fmt to ensure proper formatting.
  • ALWAYS run make mocks if 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:

  1. Basic Scheduler Creation: Verify you can create a scheduler with gocron.NewScheduler()
  2. Job Creation: Verify you can create jobs with various JobDefinition types
  3. Scheduler Lifecycle: Verify Start() and Shutdown() work correctly
  4. 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.go is 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 files

Key Source Files

  • scheduler.go - Main scheduler implementation
  • job.go - Job definitions and scheduling logic
  • executor.go - Job execution engine
  • logger.go - Logging interfaces and implementations
  • distributed.go - Distributed scheduling support
  • monitor.go - Job monitoring interfaces
  • util.go - Utility functions
  • errors.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 generation
    • github.com/jonboulle/clockwork - Time mocking for tests
    • github.com/robfig/cron/v3 - Cron expression parsing
    • github.com/stretchr/testify - Testing utilities
    • go.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 (-race flag)
  • 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 stable and oldstable (see .github/workflows/go_test.yml)

Troubleshooting

Common Issues

  1. mockgen not found: Install with go install go.uber.org/mock/mockgen@latest
  2. golangci-lint config errors: Known compatibility issue - use go vet instead
  3. Test timeouts: Tests can take 50+ seconds, always set adequate timeouts
  4. PATH issues: Ensure $(go env GOPATH)/bin is in PATH
  5. Import errors in examples: Run go mod tidy to resolve dependencies

Expected Timings

  • make test: ~50 seconds
  • make test_coverage: ~50 seconds
  • make test_ci: ~50 seconds
  • go build: ~5 seconds
  • make mocks: ~2 seconds
  • make 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

Download now (ZIP)

Trending

Quiet since September.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 3 mentionsApr 2026: 10 mentionsMay 2026: 3 mentionsJun 2026: 4 mentionsJul 2026: 11 mentionsAug 2026: 4 mentionsSep 2026: 2 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the go-co-op/gocron repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about go-co-op/gocron

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

45 more on GitHub
  • 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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.