From a88e4493c622c2a91803c0f5ce52ac272888abe8 Mon Sep 17 00:00:00 2001 From: dmathieu Date: Wed, 26 Apr 2023 12:22:29 +0200 Subject: [PATCH] only upgrade go version in genmod, don't downgrade --- scripts/genmod/go.mod | 1 + scripts/genmod/go.sum | 2 -- scripts/genmod/main.go | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/genmod/go.mod b/scripts/genmod/go.mod index 4aec1af1a..63cb96c6b 100644 --- a/scripts/genmod/go.mod +++ b/scripts/genmod/go.mod @@ -3,6 +3,7 @@ module genmod require ( github.com/pkg/errors v0.9.1 go.elastic.co/apm/v2 v2.1.0 + golang.org/x/mod v0.5.1 ) replace go.elastic.co/apm/v2 => ../.. diff --git a/scripts/genmod/go.sum b/scripts/genmod/go.sum index 5104fe5ab..2ce6d8fb0 100644 --- a/scripts/genmod/go.sum +++ b/scripts/genmod/go.sum @@ -30,8 +30,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis= -github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= diff --git a/scripts/genmod/main.go b/scripts/genmod/main.go index 5ebd539d7..006688aeb 100644 --- a/scripts/genmod/main.go +++ b/scripts/genmod/main.go @@ -33,6 +33,7 @@ import ( "strings" "github.com/pkg/errors" + "golang.org/x/mod/semver" "go.elastic.co/apm/v2" ) @@ -138,7 +139,7 @@ func updateModule(dir string, gomod *GoMod, modules map[string]*GoMod) error { "-require", require.Path + "@" + *versionFlag, "-replace", require.Path + "=" + relDir, } - if *goVersionFlag != "" { + if *goVersionFlag != "" && semver.Compare("v"+*goVersionFlag, "v"+gomod.Go) == 1 { args = append(args, "-go", *goVersionFlag) } cmd := exec.Command("go", args...)