-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
P2should be fixed if one has timeshould be fixed if one has timebrainstormingLong term ideas/discussion/requests for feedbackLong term ideas/discussion/requests for feedbackgolang/build systemRelated to the go language and compilerRelated to the go language and compilerintermediateIssues suitable for developers moderately familiar with the codebase and LNIssues suitable for developers moderately familiar with the codebase and LN
Description
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,
.
├── btcsuite
├── lnd
...
Now create the workspace using,
go work init
go work use -r ./lnd
go work use -r ./btcsuiteWhich will go through all the modules under ./lnd and ./btcsuite, add them to the go.work file.
IMPORTANT: Remember to remove ./lnd/tools from the go.work file.
You can also run go work sync to update the go.mod for every module.
And your dir would look like,
.
├── btcsuite
├── go.work
├── go.work.sum
├── lnd
...
This approach has a few pros and cons.
Pros,
- modules are imported locally in
lnd. I can easily edit the submodules and see the effect. For instance, runningmake unit tags="kvdb_sqlite" pkg=kvdbwould now give me an error. - by running
go work syncI can easily update the dependant module versions across all submodules. goplsis now happy when working in submodules.
Cons,
- as long as you are in the same or child dir of
go.work, you can rungo work syncto updatego.mod. This can also be a pro, but it will create diffs inbtcdandbtcwalletin their current branch and this can be annoying. - our CI builds
lnddifferently 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 a go.work under lnd won't suit our case.
- update development docs about creating and using
go.work - add a new make command,
check-gomod, that checks all thego.modfiles are up-to-date - we could create a temporarygo.workfile and rungo work syncandgo mod tidy, fail the check if there are uncommitted changes. This should be built into our github actions. - consider creating repo for submodules. This may seem cumbersome at first, but with
go.work, working on them locally should be seamless and, it makes us less likely to forget to update submodule versions inlnd.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2should be fixed if one has timeshould be fixed if one has timebrainstormingLong term ideas/discussion/requests for feedbackLong term ideas/discussion/requests for feedbackgolang/build systemRelated to the go language and compilerRelated to the go language and compilerintermediateIssues suitable for developers moderately familiar with the codebase and LNIssues suitable for developers moderately familiar with the codebase and LN