oleiade / reflections

High level abstractions over the Go reflect library
https://pkg.go.dev/github.com/oleiade/reflections
MIT License
524 stars 51 forks source link

no need update to 1.22 #24

Closed xiaotushaoxia closed 2 months ago

xiaotushaoxia commented 2 months ago

I use go1.21 in some projects, when I update some dependance I see

go: github.com/oleiade/reflections@v1.1.0 requires go >= 1.22.6 (running go 1.22.4)

see commit log, the only reason update to 1.22 is "for i := range fieldCount", but old code "for i:=0;i<fieldCount;i++" works well. so why update to go 1.22? code that works in lower go versions can work in higher go version, but code that works in high go versions may not work in lower go version

oleiade commented 2 months ago

Hi @xiaotushaoxia 👋🏻

For context, this project is more than ten years old at this point, and I like to periodically make sure it remains up to date. Whenever this happens some complain when I don't update the Go dependency, and some complain when I do. This time, I decided to update it, so this issue falls in the latter category 🙂

As you have noticed, most changes were about refreshing the codebase, thus I believe setting your dependency on reflections to v1.0.1 explicitly should address your issue, and you won't miss out on anything.

Note that as I look into bringing some new features to the library, we might even switch to Go 1.23 in the future, but as it will come with new APIs that should justify a v2.0.0, which your go project won't upgrade to automatically anyway.

xiaotushaoxia commented 2 months ago

hello @oleiade Mainly this reflections dont use the features of higher versions of go, and lower versions can provide better compatibility.(private opinions)

oleiade commented 2 months ago

Hey @xiaotushaoxia 👋🏻

I appreciate your perspective on this, and I'm sorry if it has caused trouble on your side. I'm well aware of the tradeoffs I've made by deciding to update the Go version. Thanks again for bringing this to my attention 🙇🏻