I have a Go project with structure somewhat like this
github.com/my/coolproject
│
└───project
│ file1.go
│ file2.go
│ go.mod (github.com/my/coolproject/project)
│ ...
│
└───package1
│ file1.go
│ file2.go
│
...
│
packagex
│ file1.go (import github.com/my/coolproject/project/package1)
│ file2.go
I would like to create v2 of the project but not sure how to go about doing that.
I tried creating v2 directory at the root of the repo, copy content of the project folder into it and update the go.mod file to github.com/my/coolproject/project/v2
With this I also had to update the imports to v2 however the directory structure now didn't match precisely so I had to change imports from
import github.com/my/coolproject/project/something to import github.com/my/coolproject/v2/something removing the 'project' and adding 'v2'.
This causes bunch of cannot find module ... errors, when I remove the 'project' from the go.mod module path in v2 then it starts working.
However now there is a difference between the original project import path and the v2
github.com/my/coolproject/project for the original vs v2 github.com/my/coolproject/v2
Is there a way how to keep the original with just v2 at the end? The problem is that then it doesn't really match the folder structure. I though about moving the v2 folder with new version into the project folder, but that sounds like a bad idea.