Hello Everyone
I have a repository that I I have split into a child package/library/repository and a parent repository. I have both in separate VSCode projects.
So when I update the child and want the parent to catchup , I currently:
commit a new version of child
sync (push) the commit
copy the commit id
switch to the parent VS Code editor
use go get -u <githuburl>@<commitid>
This works (but is a bit of a pain). But more importantly sometimes my child commit doesn’t work so I have to bounce back and forth between parent and child committing new version of child until things are working again (creating spurious commits)…
What I would like to do is :
save to child
Run parent with local copy of child
When it’s working - then do the child commit+push
N.B. I still need to run/build parent with the commit child to check deployment for other users. I might need another VSCode project just for this…that basically pulls from both latest commits…
Does anyone have a better approach that they have been using?
Hello there. You can do it in couple of ways. The one with just go.mod file, is to add replace into the file with the path to the local copy. But my preferred option is to use go.work instead. It allows you to develop packages which are part of other projects you have and test them locally, before pushing anything into git. Official docs can be found here.
I did try go work but it meant I had all my code base visible from one project. I want the child code to be separate from the parent code - I use two VSCode editors (one dark mode, the other light) when editing - it helps separate the responsibilities and my focus. I tend to work on the child (API) and then switch to/from the parent framework at need.
Thank you anyway - replace is really useful - Andy
A small update for those considering a similar approach, i.e. using ‘replace’.
The VSCode ‘parent’ editor sometimes gets out of date with ‘child’ code updates. This can be fixed by either restarting the parent editor or by using (on windows) Ctrl-Shift-P then choose Developer: Reload Window (on the parent editor).