Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context.AfterFunc is not included in Go version 1.20.x , but used in this library. #241

Closed
tomatod opened this issue Feb 17, 2024 · 1 comment · Fixed by #245
Closed
Labels
bug Something isn't working

Comments

@tomatod
Copy link
Contributor

tomatod commented Feb 17, 2024

Thank you so much for developing this library. While I'm trying this library, There's a problem with test, so please let me an report. I'm sorry if i was wrong.

Describe the bug
This library's go version is 1.20 (or later) according to go.mod, But context.AfterFunc is used in Connect function in paho/client.go .

But, context.AfterFunc is not included inGo version 1.20.x. It has been offered from version 1.21.x .

To reproduce
After you switch to Go version 1.20.x and make test, you can get an error like the following.

$ go version
go version go1.20.13 linux/amd64

$ make test
go test -coverprofile /tmp/autopaho_coverage.out -race -tags=unittest ./autopaho/ -v -count 1
# github.com/eclipse/paho.golang/paho
paho/client.go:337:10: undefined: context.AfterFunc
FAIL    github.com/eclipse/paho.golang/autopaho [build failed]
FAIL
make: *** [Makefile:4: unittest] Error 1

Expected behaviour
Test should be passed

Additional context
The specified Go version in this library probably is required upgrading.

Best Regards,

@MattBrittan
Copy link
Contributor

You are correct; it does use context.AfterFunc (I introduced this in January). I probably jumped the gun by a month or so on this. It would be possible to remove the call to context.AfterFunc but doing so would complicate things a bit, so I think it's best to just move to supporting v1.21+.

I aim to support Go releases that are supported by the Go team (i.e. current version and one previous version); however I really only test with the latest release and don't update go.mod unless I notice that I'm using a new feature. Now that Go 1.22 is out, we support Go 1.21+ and, as you say, should update the go.mod to reflect this.

@MattBrittan MattBrittan added the bug Something isn't working label Feb 17, 2024
MattBrittan added a commit to ChIoT-Tech/paho.golang that referenced this issue Feb 26, 2024
Update to Go version is in line with "Each
major Go release is supported until there are
two newer major releases". It's also needed
due to the use of `context.AfterFunc`.

Closes eclipse#241
MattBrittan added a commit that referenced this issue Feb 26, 2024
Update to Go version is in line with "Each major Go release is supported until there are two newer major releases". It's also needed due to the use of `context.AfterFunc`.

Closes #241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants