oliver006 / redis_exporter

Prometheus Exporter for ValKey & Redis Metrics. Supports ValKey and Redis 2.x, 3.x, 4.x, 5.x, 6.x, and 7.x
https://github.com/oliver006/redis_exporter
MIT License
3.12k stars 876 forks source link

Use go 1.20 in `go.mod` #812

Closed Ma27 closed 1 year ago

Ma27 commented 1 year ago

This seems to work fine considering that it's already used for all build containers. Also, when building 1.51 on NixOS, I get the following build-error:

vendor/golang.org/x/sys/unix/syscall.go:83:16: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
vendor/golang.org/x/sys/unix/syscall_linux.go:1018:20: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
vendor/golang.org/x/sys/unix/syscall_linux.go:2289:9: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
vendor/golang.org/x/sys/unix/syscall_unix.go:118:7: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
vendor/golang.org/x/sys/unix/sysvshm_unix.go:33:7: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)

Upgrading the directive and running go mod tidy solves the problem.

coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 154


Totals Coverage Status
Change from base Build 153: 0.0%
Covered Lines: 1920
Relevant Lines: 2075

💛 - Coveralls
oliver006 commented 1 year ago

Can you rebase you PR please?

Also, are there any downsides to upgrading the go version in go.mod? I think it shouldn't affect what Go toolchain is used (that should only change in 1.21, I think)

Ma27 commented 1 year ago

Can you rebase you PR please?

@oliver006 Done!

Also, are there any downsides to upgrading the go version in go.mod?

None that I'm aware of. We can probably try out 1.19 as well, but any older version is not supported by Go anyways, so it shouldn't be a big deal: https://endoflife.date/go

I think it shouldn't affect what Go toolchain is used (that should only change in 1.21, I think)

The version is only enforced at 1.21, but not before. However it appears to imply some behavioral changes: https://go.dev/doc/modules/gomod-ref#go-notes

Also, the value is passed to the -lang option of the compiler (as implied by the error I posted above) and that causes the problem when unsafe.Slice is attempted to be used (as done by golang.org/x/sys here).

oliver006 commented 1 year ago

Thanks @Ma27 - make sense. Let's do it.