Querying Direct and Indirect Dependencies
To view minor and patch updates for both direct and indirect dependencies, execute go list -u -m all. This lists all dependencies of your project, including those inherited transitively.
Alternatively, you can use the third-party app go-mod-outdated to obtain a table view of available updates for both direct and indirect dependencies.
Limiting to Direct Dependencies
If you're interested only in direct dependencies, employ the -f flag to specify a custom output format. For example:
go list -u -m -f '{{if not .Indirect}}{{.}}{{end}}' all
This prints only the direct dependencies that have updates, as it evaluates the not .Indirect condition for each dependency.
Listing Dependencies Without Updates
To list only dependencies without updates, filter out those with an Update field:
go list -u -m -f '{{if .Update}}{{.}}{{end}}' all
The above is the detailed content of How Can I Identify Outdated Go Dependencies (Direct and Indirect)?. For more information, please follow other related articles on the PHP Chinese website!