Modules for packages without dependencies

61 views
Skip to first unread message

Robert Johnstone

unread,
Sep 13, 2019, 10:36:39 AM9/13/19
to golang-nuts
Hello,

I'm looking at what I should do to keep my packages current with respect to modules.  The tutorials have covered top-level packages, but I haven't seen any discussions around low-level packages.  In particular, I have some low-level packages that rely only on the standard library.  It's not clear whether or not these packages should have a go.mod file.  At most, it would specify the minimum version of go.  I don't see much impact on usability or maintenance either way.

For vendoring, it was best practice (?) that only top-level packages would vendor.  I'm wondering if this rule applies to modules.

Robert

Ian Lance Taylor

unread,
Sep 13, 2019, 2:00:44 PM9/13/19
to Robert Johnstone, golang-nuts
My understanding is that adding a go.mod file is a good idea even for
low-level libraries, in that it gives you a way to set a version
number for your library that your users will be able to use. You can
then increment the version number as appropriate to indicate patches,
minor updates, or even major version updates. See
https://blog.golang.org/migrating-to-go-modules for more background on
turning your library into a module.

Of course, if you plan to never change your library again, or if the
library has no users, then this doesn't matter.

Ian
Reply all
Reply to author
Forward
0 new messages