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

v4.43.1 doesn't build with go <1.21 #2001

Closed
TheMysteriousX opened this issue Apr 7, 2024 · 2 comments
Closed

v4.43.1 doesn't build with go <1.21 #2001

TheMysteriousX opened this issue Apr 7, 2024 · 2 comments

Comments

@TheMysteriousX
Copy link

Describe the bug
I'm not sure what your policy for supporting older go runtimes is, mostly raising this in case anyone else bumps into it.

RHEL8 ships with go 1.20, yq v4.43.1 doesn't build with this runtime:

...
DEBUG: # github.com/mikefarah/yq/v4/pkg/yqlib
DEBUG: pkg/yqlib/operator_omit.go:9:47: undefined: max
DEBUG: pkg/yqlib/operator_omit.go:25:47: undefined: max
DEBUG: note: module requires Go 1.21
...

Which appears to point at #1989 - possibly other changes too, however the build stops at the first fault it encounters.

v4.42.1 still builds absolutely fine on 1.20

Version of yq: 4.43.1
Operating system: linux
Installed via: rpm

Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
data1.yml:

n/a

Command
The command you ran:

n/a

Actual behavior

n/a

Expected behavior

n/a

Additional context
n/a

@julthomas
Copy link

Hello,

The requirement on go 1.21 was set in commit bbe196b "feat: upgrade go.mod to 1.21 (#1830)". This is related to the patch on pkg/yqlib/operator_omit.go because it uses a max() function that is apparenty not available in go 1.20. Preserving go 1.20 compatibility would be great because that version is available in el8 and el9.

So far I was able to build our RPM package without too much hassle that patch:

--- a/go.mod
+++ b/go.mod
@@ -30,4 +30,4 @@ require (
        golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
 )
 
-go 1.21
+go 1.20
--- a/pkg/yqlib/operator_omit.go
+++ b/pkg/yqlib/operator_omit.go
@@ -5,6 +5,13 @@ import (
        "strconv"
 )
 
+func max(a, b int) int {
+    if a > b {
+        return a
+    }
+    return b
+}
+
 func omitMap(original *CandidateNode, indices *CandidateNode) *CandidateNode {
        filteredContent := make([]*CandidateNode, 0, max(0, len(original.Content)-len(indices.Content)*2))

Regards,
Julien

@mikefarah
Copy link
Owner

Sorry yq does not have backwards compatibility for older versions of go. Often the go version is bumped for security issues.

julthomas added a commit to zenetys/rpm-yq that referenced this issue Nov 3, 2024
As per mikefarah/yq#2001, building yq requires
a golang version newer than the one available in el8 and el9. Let's use
prebuilt binaries from the go project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants