When there are no external dependencies, is there a need for go.mod?

All of my old projects use the gopath. I converted one of my projects to modules and the go.mod and go.sum work fine.

I then tried to convert another old project and realized that there are no external dependencies. Actually most of my projects only use the standard library. When running the go mod init command I realized that my go.mod is pretty empty; there are no external dependencies. Also running go build does not create a go.sum file because there are no dependencies (I’m assuming).

So if there are no external dependencies is it still necessary to make the project a module?

If you want to use it as a dependency from a project that is a module, yes.

Actually all the cases that I am thinking of are not intended to be libraries. They are standalone programs with their own main(). So in that case using a module is unnecessary? I guess I should have asked that in my question instead :slight_smile:

Personally I’d still prefer go modules, as they are easier to package on nixOS, also I can place them on my harddisk where I want them, and not where Google wants me to put them. GOPATHs structure doesn’t suite my organisation I use usually for my projects.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.