-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: go mod tidy
does not remove useless tools
#71819
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
Comments
go mod tidy
does not remove useless tools
I believe this is working as intended: tools may be invoked manually without any other references to it in code. We do not want to remove tools that are used. |
tools that are used - yes but how to manage not used ones? |
you remove them from go.mod directly, or remove them via |
yes, correct, but this look like not a go way For example: in php dependencies can be installed and removed ONLY MANUALLY it does not have same useful command like so, php has a big problem with useless libraries in projects. And there is a fix solutions around it https://github.com/composer-unused/composer-unused golang run its own really simple way with dependencies why does it works with dependencies, but does not work with tool? |
why golang try to simplify developer experience and life as much as possible but in this case - "no. Suffer!" it is strange.
on the other side - if I forgot to remove tools - they still be in project. No more simple dependency managements. Just need to manually remove. But why?) If you already show that there is a simple way |
As @seankhliao mentioned, the Think of the |
got u actually, why I ask this? because, for example - I'm working with hundreds of microservices some of them use tools, other - dont it looks very useful to add tools in services where they need. but - programmer is always lazy. I not expect that they always keep tracking use they tool in service or not so, human can add it once, and forget to remove and some instruments that help him remove this mistake seems like a pleasure easier to remove - easier to use but okay( |
Go version
go1.24
Output of
go env
in your module/workspace:Introduction
go1.24 has a great feature -
go tool
this looks so cool. Add a library as tool and reuse it.
but what if i add a library as tool, then use it, and then change this library on another library
so, the library 1 is not used anymore in project
In case of simple go.mod dependency - this is not a problem. Just run
go mod tidy
and all useless libraries should remove from itbut, if i have useless tool -
go mod tidy
does not react.What did you do?
install library
then use it in file
then remove
go:generate
line, so the project does not use enumer nowthen
go mod tidy
What did you see happen?
tool is still in project, with all its dependencies
What did you expect to see?
if tool is usable through the project - it locates in go.mod and
go mod tidy
does not remove itif tool is not usable -
go mod tidy
must remove it like as other simple dependenciesThe text was updated successfully, but these errors were encountered: