Sometimes you just want to be able to modularize/namespace your code without having to make a full-fledged library out of it.
Go seems to discourage this sort of this as of 1.16 and wants you make a separate remote repo to house such code,
and then you can import
it into your main project.
Unless I'm missing something, this feels like Go discourages local namespacing of code within a single project.
But there is a way to accomplish this even if it's not considered idiomatic.
- Relative to the root directory of your project, first create a new directory within your main project to house a local module, in this example
zomg
. - Then from within that directory create a new file, say,
zomg.go
, and put the following in it: