How to Find Indirect Dependency in Golang? Last Updated : 15 Jul, 2024 Comments Improve Suggest changes Like Article Like Report Go, also known as Golang, is a statically typed, compiled language with a rich standard library and a robust ecosystem of packages. When building Go applications, it’s common to use third-party packages to avoid reinventing the wheel. However, these packages can have their own dependencies, known as indirect dependencies. This article provides a detailed guide on how to find indirect dependencies in Go.Table of ContentUnderstanding Direct and Indirect DependenciesThe Go ModulesHow to Find Indirect Dependencies In Golang?ConclusionFAQsUnderstanding Direct and Indirect DependenciesIn Go, a direct dependency is a package that your code imports directly. An indirect dependency, on the other hand, is a package that your direct dependencies import.For example, if your Go application imports package A, and package A imports package B, then package A is a direct dependency and package B is an indirect dependency.The Go ModulesGo Modules is the official dependency management solution in Go. It was introduced in Go 1.11 and became the default in Go 1.16. With Go Modules, you can manage your project’s dependencies in a straightforward and reproducible way.The go.mod file in your project root defines the module path (the import path used in Go source code) and the Go version your project is using. It also lists the specific versions of the direct dependencies your project uses.The go.sum file, on the other hand, includes cryptographic checksums of the exact code for each dependency your project uses, both direct and indirect. This ensures that you’re always using the same code for each dependency, improving the reproducibility of your builds.How to Find Indirect Dependencies In Golang?You can use the go list command to find the indirect dependencies of your Go application. The -m flag tells go list to list modules instead of packages, and the all keyword tells it to list all modules needed to build packages in your module.Here’s how you can use it:go list -m allThis will print a list of all direct and indirect dependencies your application uses, along with their versions.If you want to list only the indirect dependencies, you can use the go mod graph command and filter out the direct dependencies:go mod graph | awk '{if ($1 != "main") print $2}' | sort | uniqIn this command, go mod graph prints the module requirement graph, awk filters out the direct dependencies, and sort | uniq sorts the list and removes duplicates.ConclusionUnderstanding and managing dependencies, both direct and indirect, is a crucial part of developing Go applications. With Go Modules and the built-in Go commands, you can easily find and manage your application’s dependencies in a straightforward and reproducible way.Remember, keeping your dependencies up-to-date and minimizing the number of unnecessary dependencies can help you avoid potential issues and vulnerabilities. Happy coding! Comment More infoAdvertise with us Next Article How to Find Indirect Dependency in Golang? V vishantvekhmb Follow Improve Article Tags : Articles Go Language Similar Reads SQL Joins (Inner, Left, Right and Full Join) SQL joins are fundamental tools for combining data from multiple tables in relational databases. Joins allow efficient data retrieval, which is essential for generating meaningful observations and solving complex business queries. Understanding SQL join types, such as INNER JOIN, LEFT JOIN, RIGHT JO 6 min read What is a Neural Network? Neural networks are machine learning models that mimic the complex functions of the human brain. These models consist of interconnected nodes or neurons that process data, learn patterns, and enable tasks such as pattern recognition and decision-making.In this article, we will explore the fundamenta 14 min read Go Tutorial Go or you say Golang is a procedural and statically typed programming language having the syntax similar to C programming language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language and mainly used in Google 2 min read Why is Analysis of Algorithm important? Why is Performance of Algorithms Important ? There are many important things that should be taken care of, like user-friendliness, modularity, security, maintainability, etc. Why worry about performance? The answer to this is simple, we can have all the above things only if we have performance. So p 2 min read GeeksforGeeks Master Sheet - List of all Cheat Sheets In this Master Sheet, weâll cover all the important cheat sheets like SDE Sheets, DSA Topics Sheets, HTML, CSS, JavaScript, React, Angular, Bootstrap, jQuery, Python, Data Science, C, C++, Java, Computer Networks, Company Wise SDE sheets, etc. GFG Master Sheet - A Collection of all Cheat Sheets What 10 min read The Complete History of Java Programming Language Java is an Object-Oriented programming language developed by James Gosling in the early 1990s. The team initiated this project to develop a language for digital devices such as set-top boxes, televisions, etc. Originally, C++ was considered to be used in the project, but the idea was rejected for se 5 min read Go Programming Language (Introduction) Go is a procedural programming language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language. Programs are assembled by using packages, for efficient management of dependencies. This language also supports env 11 min read SQL AND and OR Operators The SQL AND and OR operators are used to filter data based on multiple conditions. These logical operators allow users to retrieve precise results from a database by combining various conditions in SELECT, INSERT, UPDATE, and DELETE statements.In this article, we'll learn the AND and OR operators, d 3 min read Difference Between Object And Class Class is a detailed description, the definition, and the template of what an object will be. But it is not the object itself. Also, what we call, a class is the building block that leads to Object-Oriented Programming. It is a user-defined data type, that holds its own data members and member functi 6 min read How message authentication code works? Prerequisite - Message authentication codes Apart from intruders, the transfer of message between two people also faces other external problems like noise, which may alter the original message constructed by the sender. To ensure that the message is not altered there's this cool method MAC. MAC stan 2 min read Like