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

go.mod: bump minimum and language to 1.21 #949

Merged
merged 2 commits into from
May 24, 2024
Merged

Conversation

mvdan
Copy link
Contributor

@mvdan mvdan commented May 3, 2024

(see commit message)

CI only tests Go 1.21 and 1.22, and older versions of Go are no longer
getting any bug or security fixes, so advertise that we only support
Go 1.21 or later via go.mod.

While here, ensure the module is tidy and resolve deprecation warnings,
and remove now-unnecessary Go version build tags.
@pelletier
Copy link
Owner

pelletier commented May 5, 2024

Thank you for submitting a PR!

My current stance on this is #938. In other words, I'm not fundamentally against bumping the minimum go version, but only if there is a clear benefit to it. Since it would be preventing people stuck on older versions to use the library, the trade-off needs to be appealing.

The readme advertises that only the last two versions of Go are supported, but a best effort to keep compatibility versions seem fine to me.

Is it causing any issue or preventing you to do something on your end?

@mvdan
Copy link
Contributor Author

mvdan commented May 9, 2024

Interesting - I tend to take the opposite stance, I bump go.mod as soon as my minimum supported Go version goes up. Any older Go version stops being tested in CI, so for me personally, the support is already gone. Even if the code happens to still build on a slightly older Go version, I'm not testing it, so all bets are off. It's in my opinion better to signal that via a minimum version in go.mod than to leave the users in a bit of a limbo.

Nowadays there shouldn't be an excuse to stay on an older and unsupported Go version (without security updates even), particularly given https://go.dev/doc/toolchain :)

In practical terms, yes, it would be very nice to be able to use newer std additions and generics. As master is right now, we only test on Go 1.21+, but we are not able to use any standard library APIs added after 1.16, which is contradictory.

The latter is more efficient, and allocates less, since sort.Slice
needs to go through sort.Interface which causes allocations.

    goos: linux
    goarch: amd64
    pkg: github.com/pelletier/go-toml/v2/benchmark
    cpu: AMD Ryzen 7 PRO 5850U with Radeon Graphics
                              │     old     │                new                 │
                              │   sec/op    │   sec/op     vs base               │
    Marshal/HugoFrontMatter-8   7.612µ ± 1%   6.730µ ± 1%  -11.59% (p=0.002 n=6)

                              │     old      │                 new                 │
                              │     B/s      │     B/s       vs base               │
    Marshal/HugoFrontMatter-8   65.52Mi ± 1%   74.11Mi ± 1%  +13.11% (p=0.002 n=6)

                              │     old      │                new                 │
                              │     B/op     │     B/op      vs base              │
    Marshal/HugoFrontMatter-8   5.672Ki ± 0%   5.266Ki ± 0%  -7.16% (p=0.002 n=6)

                              │    old     │                new                │
                              │ allocs/op  │ allocs/op   vs base               │
    Marshal/HugoFrontMatter-8   85.00 ± 0%   73.00 ± 0%  -14.12% (p=0.002 n=6)
@pelletier
Copy link
Owner

The performance improvement is worth the bump. Let's do it!

@pelletier pelletier merged commit 9b890cf into pelletier:v2 May 24, 2024
11 checks passed
@mvdan mvdan deleted the go-1.21 branch May 24, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants