Working on (and compiling) modules locally when remote also exists

I want to work on a module locally and compile it locally before pushing changes to git. Here’s the scenario:

Module A

module git.projectx.org.org/xproj/A

go 1.14

require (
	git.projectx.org/xproj/B v0.0.0-20200620073245-b5659b460fc5
)

Module B

module git.fidozero.org/a/xdb

go 1.14

As can be seen above, both modules are using git version control. Module A is using module B as an import.

How do I work on module B locally, make changes etc, and then compile module A so that it uses these new local changes in module B instead of go trying to use the remote repository?

This is necessary in order to use the git fork/pull development model (fork, clone locally => make local changes, make sure tests pass etc etc etc => push to remote fork, create pull request back to remote upstream).

1 Like

I’m interested to hear what others have to say because I haven’t started using modules yet. This is one of the reasons I haven’t.

1 Like

There’s a quick FAQ here https://github.com/golang/go/wiki/Modules#can-i-work-entirely-outside-of-vcs-on-my-local-filesystem

2 Likes