lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.64k stars 2.08k forks source link

workspace: leverage `go.work` to manage submodules #7958

Open yyforyongyu opened 1 year ago

yyforyongyu commented 1 year ago

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 ./btcsuite

Which 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,

Cons,

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.

Roasbeef commented 1 year ago

IMPORTANT: Remember to remove ./lnd/tools from the go.work file.

Why's this step required?

yyforyongyu commented 1 year ago

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.