Notice the following:
- The greeting package is called
greetingin both thev1andv2directories. - The greeting package is NOT called
v1orv2like how it is in this Kubernetes example. - Note that I have a single
go.modfile in the root directory, wheremain.gois. - The first line in the
go.modfile ismodule github.com/codegold79/simple-versioning-with-go. That sets the namespace for all the packages in the repo. - I ran
go mod tidyto bring in dependencies (probably not needed, but good practice). - Run
go run main.goand see that I can use whatever package I imported usinggreeting.
Try it out yourself. Change the import path to V2 and see the greeting change. You didn't need to reset all the imported package aliases and update them all in the code.