Empty go.mod file in root directory containing only version maps

292 views
Skip to first unread message

Gert

unread,
Oct 22, 2019, 2:42:34 AM10/22/19
to golang-nuts

Example https://github.com/gertcuykens/module/tree/v4.0.0 can I assume it to be good practice to put a empty go.mod file in the root directory that doesn't contain other go files, only the version folders, so the root itself doesn't get recognised as a module itself?

t hepudds

unread,
Oct 22, 2019, 11:03:26 AM10/22/19
to golang-nuts
Hello Gert,

It looks like you are experimenting with the "major subdirectory" layout for modules.

It looks like your v1 module is incorrectly specified, including with an incorrect trailing "/v1":


Usually you would not have a "/v1" subdirectory if you are following the "major subdirectory" layout. If you have the v1 module in the same branch as your v2, v3, and v4 modules, then usually the v1 module would be in the root directory of the repo, and not a /v1 subdirectory, and there would be no traililng "/v1" on the module line of the go.mod there.

This is described in more detail here:


Note that section also describes an alternative layout called the "major branch" layout for modules, which does not use any "/vN" subdirectories, and which some people find simpler to manage at this point.

There is also a much longer discussion of those two alternative layouts here:

In summary, I think the answer to your question is "no, that is not a standard practice".

Regards,
thepudds

Gert

unread,
Oct 22, 2019, 12:33:27 PM10/22/19
to golang-nuts
Thanks, the branch approach makes much more sense https://github.com/gertcuykens/module/tree/v5.0.0
Reply all
Reply to author
Forward
0 new messages