-
Notifications
You must be signed in to change notification settings - Fork 38
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
Use existing go version in go mod tidy an verify #242
Conversation
da7fcb2
to
34c7a7d
Compare
Makefile
Outdated
@@ -74,14 +74,14 @@ $(BINARIES): bin/%: | |||
mod-tidy: | |||
$(Q)for mod in $$(find . -name go.mod); do \ | |||
echo "Tidying $$mod..."; ( \ | |||
cd $$(dirname $$mod) && go mod tidy \ | |||
cd $$(dirname $$mod) && go mod tidy -go=$$(grep -E "go\s+\d\.\d+" go.mod | sed 's/go //') \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe it's just me but my gut feeling would like that 'go ' pattern to be forced to only match at the beginning of the line with "^go...".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
Makefile
Outdated
) || exit 1; \ | ||
done | ||
|
||
mod-verify: | ||
$(Q)for mod in $$(find . -name go.mod); do \ | ||
echo "Verifying $$mod..."; ( \ | ||
cd $$(dirname $$mod) && go mod verify | sed 's/^/ /g' \ | ||
cd $$(dirname $$mod) && go mod verify -go=$$(grep -E "go\s+\d\.\d+" go.mod | sed 's/go //') | sed 's/^/ /g' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ditto here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, although I have a nit-desire related to forcing the go...
pattern to be matched only at the beginning of a line.
34c7a7d
to
a81fdad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Makefile
Outdated
@@ -74,14 +74,14 @@ $(BINARIES): bin/%: | |||
mod-tidy: | |||
$(Q)for mod in $$(find . -name go.mod); do \ | |||
echo "Tidying $$mod..."; ( \ | |||
cd $$(dirname $$mod) && go mod tidy \ | |||
cd $$(dirname $$mod) && go mod tidy -go=$$(grep -E "^go\s+\d\.\d+$$" go.mod | sed 's/^go //') \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grep -E "^go\s+\d\.\d+$$" go.mod
doesn't output anything in my env:
$ grep -E "^go\s+\d\.\d+$" go.mod || echo nope
nope
I think grep
doesn't understand \d
pattern, does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
container-device-interface git:(producer-api) ✗ grep -E "^go\s+\d\.\d+$" go.mod | sed 's/^go //'
1.20
grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go 1.20
➜ container-device-interface git:(fix-go-mod-tidy) ✗ grep -E "^go\s+[1-9]\.[0-9]+$" go.mod
go 1.20```
a81fdad
to
b07eb4c
Compare
@@ -74,14 +74,14 @@ $(BINARIES): bin/%: | |||
mod-tidy: | |||
$(Q)for mod in $$(find . -name go.mod); do \ | |||
echo "Tidying $$mod..."; ( \ | |||
cd $$(dirname $$mod) && go mod tidy \ | |||
cd $$(dirname $$mod) && go mod tidy -go=$$(grep -E "^go\s+[1-9]\.[0-9]+$$" go.mod | sed 's/^go //') \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure I understand the intent of the change.
According to the go mod tidy
help output
The -go flag causes tidy to update the 'go' directive in the go.mod
file to the given version
However, updating the directive to the version from the same file does nothing, doesn't it?
Makefile
Outdated
) || exit 1; \ | ||
done | ||
|
||
mod-verify: | ||
$(Q)for mod in $$(find . -name go.mod); do \ | ||
echo "Verifying $$mod..."; ( \ | ||
cd $$(dirname $$mod) && go mod verify | sed 's/^/ /g' \ | ||
cd $$(dirname $$mod) && go mod verify -go=$$(grep -E "^go\s+[1-9]\.[0-9]+$$" go.mod | sed 's/^go //') | sed 's/^/ /g' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go mod verify
doesn't have -go
command line option according to its help page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Updated.
This change ensures that running make mod-tidy doesn't update the go version specified in the mod files. Signed-off-by: Evan Lezar <[email protected]>
b07eb4c
to
da3dc1c
Compare
Actually, I think I missed something here. There reason my I'm going to close this PR as unneeded since setting Sorry for the back and forth. |
This change ensures that running make mod-tidy doesn't update the go version specified in the mod files.