Open yyforyongyu opened 1 year ago
IMPORTANT: Remember to remove ./lnd/tools from the go.work file.
Why's this step required?
Why's this step required?
I think it's because the tools
package is used to pin versions for the tools we use in builds, not related to the actual code of lnd
. The last time I tried to include it, I got quite some errors when running github actions. There may be a catch I'm missing here.
Locally, I use go workspace to please
gopls
so it's easier to work in submodules. Here's the approach,Suppose you have a similar dir structure as the following,
Now create the workspace using,
Which will go through all the modules under
./lnd
and./btcsuite
, add them to thego.work
file.IMPORTANT: Remember to remove
./lnd/tools
from thego.work
file.You can also run
go work sync
to update thego.mod
for every module.And your dir would look like,
This approach has a few pros and cons. Pros,
lnd
. I can easily edit the submodules and see the effect. For instance, runningmake unit tags="kvdb_sqlite" pkg=kvdb
would now give me an error.go work sync
I can easily update the dependant module versions across all submodules.gopls
is now happy when working in submodules.Cons,
go.work
, you can rungo work sync
to updatego.mod
. This can also be a pro, but it will create diffs inbtcd
andbtcwallet
in their current branch and this can be annoying.lnd
differently by using older submodules, and we may still forget to tag their versions.Solutions
There's ongoing debate about whether
go.work
should be checked into VCS. Because we have multiple projects,taproot-assets
,loop
,pool
, etc, adding ago.work
underlnd
won't suit our case.go.work
check-gomod
, that checks all thego.mod
files are up-to-date - we could create a temporarygo.work
file and rungo work sync
andgo mod tidy
, fail the check if there are uncommitted changes. This should be built into our github actions.go.work
, working on them locally should be seamless and, it makes us less likely to forget to update submodule versions inlnd
.