I am working on two Go projects at the same time, let's call the first one myApp and the second one my-sdk , both are seperate Golang projects. Both myApp and my-sdk are under development at the same time and it is common for myApp to use the latest version of my-sdk

Current Approach: The current approach is whenever I change my-sdk for fixing a bug or a new feature, I commit and then push to a private remote git repo (on main branch directly since I am the sole developer). I then add a new tag (e.g. v0.3.0) following semver and push it as well.

Then I go to my MyApp's myApp/go.mod and update the dependency version and run go mod tidy to re-install the latest change.

Issue: This approach works but is quite tiresome, it would have been great if both the application and SDK were stable and have infrequent changes but I am still in the early development phase and can update my-sdk more than 10 times a day and then want to test the new feature several times in myApp causing many tags to be pushed and changing go.mod several times, just in a single day.

Since both project live in my laptop (inside WSL), I was wondering if there is way to make myApp always point to the latest version or master branch of the local my-sdk without having to push and tag every change of the SDK.

Note: I thought about just moving the SDK to live inside the app project momentarily (e.g. myApp/pkg/my-sdk/*) but not sure this is the best approach since I might start a second project (anotherApp ) which would also re-use the SDK underdevelopment .

2 Replies 2

Hi Annis99!

If I understand you correctly, this is explained in the book Learning Go, 2nd Edition by Jon Bodner, in Chapter 10: Modules, Packages, and Imports, in the section “Using Workspaces to Modify Modules Simultaneously.”

I dunno if it would be correct to give you the full solution from this book. I believe you can find this chapter.

You can use the replace directive to point to a local copy of the module. As you modify the module code locally, the compiler just uses the current state of that code. No fussing with versions.

Similar question:

https://stackoverflow.com/a/74891220

The official docs offer a more robust description.

https://go.dev/doc/modules/managing-dependencies#local_directory

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.