go-co-op / gocron

Easy and fluent Go cron scheduling. This is a fork from https://github.com/jasonlvhit/gocron
MIT License
5.61k stars 308 forks source link

[BUG] - library incompatible with the go latest version 1.22.4 #748

Closed priyamgoenka1 closed 4 months ago

priyamgoenka1 commented 4 months ago

Describe the bug

When I tried using gocron in my microservice written in go. It threw error in building with message "note: module requires Go 1.20"

To Reproduce

Steps to reproduce the behaviour:

  1. Try running it for go version 1.22.4

Version

The release version or commit SHA you're using: @latest

Expected behaviour

Are you planning to move it to latest go version as I have other dependencies on my imports due to which i have to stick to latest version.

Additional context

JohnRoesler commented 4 months ago

hi @priyamgoenka1 can you share more about your project set-up that you are seeing this issue?

I am able to import gocron into a project running go 1.22.4 without issue. Here is an example:

go.mod

module myapp

go 1.22

require github.com/go-co-op/gocron/v2 v2.7.1

require (
    github.com/google/uuid v1.6.0 // indirect
    github.com/jonboulle/clockwork v0.4.0 // indirect
    github.com/robfig/cron/v3 v3.0.1 // indirect
    golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
)

main.go

package main

import (
    "fmt"
    "time"

    "github.com/go-co-op/gocron/v2"
)

func main() {
    s, err := gocron.NewScheduler()
    if err != nil {
        panic(err)
    }

    _, err = s.NewJob(
        gocron.DurationJob(
            1*time.Second,
        ),
        gocron.NewTask(
            func() {
                fmt.Println("job ran")
            },
        ),
    )
    if err != nil {
        panic(err)
    }

    s.Start()

    select {
    case <-time.After(5 * time.Second):
    }

    err = s.Shutdown()
    if err != nil {
        panic(err)
    }
}

output

> go version       
go version go1.22.4 darwin/arm64

> go run myapp/main.go                                             
job ran
job ran
job ran
job ran
job ran
JohnRoesler commented 4 months ago

Feel free to share details, but I don't believe this is a valid bug