To deal with the idiosyncratic failing test issues from my last go post, I got to do a bunch of stuff with our monorepo and learn a bit more about the Godep tool, and now I know more about why the stuff at the end of this post works.
The solution to my problem was to update the version of sqlmock that I was using. One of the potential issues with monorepos is that if you update a package, you have to update it across the entire monorepo, because of how Go dependencies work. One solution to this problem is to make whoever wants to change versions do all the updates across the repo. Another (less ‘Go’) solution is to have two versions of the dependency in your project. Which is what we did.
It took me a few tries to get everything down in a way that made both Godep and git happy, so here is my recommendation on the order of steps to take.
- Checkout your master branch and make sure it is up to date.
-
Make sure your local Godeps/_workspace is up to date by running the
godep restore
command. I think this is the one I was having the most trouble with, because ‘restore’ is not what I think I want to do, conceptually. The restore command is (I think) making your local Godep/_workspace match what is in the Godep.json file. So if you’ve messed added ore removed a whole bunch of stuff, and want to start over, the ‘restore’ command is an accurate reflection of what you are doing, but it also works as an ‘update’, which is conceptually what I thought I wanted to do. -
Check your git status and make sure you don’t see anything unexpected. In my case, I didn’t expect to see really anything in my status because our Godep folder is checked into git.
-
If you haven’t already, do a
godep get PACKAGE/I/WANT
. -
Update the import statement(s) in your actual *.go file(s).
-
To save this into your dependencies, use
godep save -r ./...
. The -r flag takes care of re-writing any import statements to now point to your Godep/_workspace folder. The./...
makes sure it checks the current folder and all folders inside of it to catch any new imports. -
Again, check your git diff. At this point, I expected to see:
– the import changes
– the new package in Godep/_workspace
If it all looks good, commit!
-
If this update was a breaking version change, now go back and fix your code that it compiles and runs again.
-
Finish the thing that sent you down this rabbit hole in the first place!