Posts

Showing posts from January, 2022

What is go.mod?

For every project in Go we create a directory with the name of the project. With in this directory we initialise with go mod init <name of the module> . What it actually do is, it creates a file named go.mod in the project directory. What it contains? It contains the name of the module and also version of go you are using and also the names of the package along with their version. What is its use? It automatically logs all the go packages and their version that are imported in the project. Why is it required? In order to answer this question one should actually know the drawbacks of other programming languages.Let's have a high level understanding. When ever an import is done, the compiler places the code of the imported file in the source code file this means that the imported file goes under compilation. So what is wrong in that? Think about what if we do not use any feature from the imported file? It is just compiling of no use. As compilation takes times ,having a few us