-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/go: go mod tidy
leaves trailing empty lines in require
blocks
#70632
Comments
CC @golang/tools-team |
Hi @seankhliao this looks like a good issue for a beginner like me, and I feel I could learn a lot from working on it. Can I give it a try if no one else is already on it? Thanks! |
@Agent-Hellboy Go for it! This would have to wait until go1.25 development starts to get submitted but you could start working on it now. This would need to be fixed in When we format the file, it should remove the blank line but it doesn't. Once we fix that and vendor the fix in go mod tidy will be fixed too. |
Hi @matloob , thanks! I have a doubt. I cloned modfile, made changes, and used my local path in imports of modfile the other day, but I was not able to build the binary. It was giving a weird error as modfile is not there in vendor. Do I need to clone it in a specific place? I guess Go is assuming it’s a standalone library inside the Go project. What’s the flow to test the changes made inside the modfile repo? |
@Agent-Hellboy So to test changes in the go command that depend on changes in the
You will then have the updated changes to You will need to rerun |
Thanks @matloob , I am able to build and test. what about updating https://go.dev/doc/contribute#where, or is it documented somewhere else ? |
Hi @matloob , I have added a PR golang/mod#22 , I am ignoring the newline during parsing of required block itself, looks like there are cleanup methods for all block but ignoring at parsing stage was easy. Tests are passing , I hope it didn't introduce any regression |
Change https://go.dev/cl/634875 mentions this issue: |
Go version
go version go1.23.3 linux/arm64
Output of
go env
in your module/workspace:What did you do?
Ran
go mod tidy
with ago.mod
that contained a stray empty line in arequire
blockReproduction steps
Create a minimal module with at least one dependency
Create a go.mod with trailing empty lines in the
require
section;Run
go mod tidy
;Check the content of
go.mod
, and observe that an empty line is left behind in therequire
section;What did you see happen?
The empty line was kept even after running
go mod tidy
What did you expect to see?
The empty line to be removed.
The text was updated successfully, but these errors were encountered: