Skip to content

Go 1.23 compatibility? #22

@StevenACoffman

Description

@StevenACoffman

Now that Go 1.25 is out, and the security and support policy is that each major Go release is supported until there are two newer major releases, we can expect most people to be on Go 1.23 or newer.

The Go module of this package has not been updated to indicate that it supports Go 1.23 however, so I wonder whether this has been verified to work correctly with Go 1.23 and newer?

For instance, at least one of the inspirations for this library, jonboulle/clockwork does NOT work correctly with Go 1.23 or newer, see jonboulle/clockwork#98

Go 1.23 comes with behavior changes in timers, check out the full article: https://go.dev/wiki/Go123Timer

In short, three important changes:

  • timers do not need to be closed if not used anymore
  • you shouldn't bother about the state of timer before calling to Reset anymore
  • channels must not be emptied after the Stop() returned false

The last part is very important, since existing calls to <-timer.Chan() now could lead to deadlocks, see godoc:

// For a chan-based timer created with NewTimer(d), as of Go 1.23, // any receive from t.C after Stop has returned is guaranteed to block // rather than receive a stale time value from before the Stop; 

https://github.com/golang/go/blob/065c1359e1bc3d6744a925339484592b13d713dd/src/time/sleep.go#L105C1-L109C47

In order to use Go 1.23+ with jonboulle/clockwork, you have to work around the issue by reproducing the pre-1.23 timers behavior and I wonder if this is also necessary with current Quartz:

func (f fakeClock) NewTimer(d time.Duration) internal.Timer { timer := f.clockworkFakeClock.NewTimer(d) if d == 0 { // Here we reproduce the pre-1.23 timers behavior since jonboulle/clockwork still have not fixed this yet, // see the issue: https://github.com/jonboulle/clockwork/issues/98 if !timer.Stop() { <-timer.Chan()	}	} return timer }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions