Circular deps between btcutil and btcd, and tons of duplicated deps with different versions because the versions are inconsistent
Start a new project go mod init foo, then go get github.com/btcsuite/btcd, then add a main.go
package main
import (
_ "github.com/btcsuite/btcd"
)
func main() {
}
```
then
`go mod tidy`.
The resulting `go.sum` has tons of duplicate deps at different versions, for example
```
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A=
The reason is that for example, [email protected] references [email protected]:
https://github.com/btcsuite/btcd/blob/d55c55a81f8f9cf2b0fa3cbb83e820ea28173081/go.mod#L5
while btcutil in turn references [email protected]
https://github.com/btcsuite/btcd/blob/d55c55a81f8f9cf2b0fa3cbb83e820ea28173081/btcutil/go.mod#L7C1-L7C64
which in turn references an older btcutil, and so on.
Not sure if there are more such instances.
I am unsure why btcutil is a module of its own, can't it just be a package inside btcd and not a module?
If it has to be a module, btcutil and btcd should ideally not depend on each other.
Barring all of that, the two should point to the same versions.
(All things aside) what was the thing you were trying to do? Maybe I could help out there. btcd's main package isn't really meant for outside usage, each of the individual packages are.
We're aware of that. Still looking for reviewers of https://github.com/btcsuite/btcd/pull/1825.
@kcalvinalvin
(All things aside) what was the thing you were trying to do? Maybe I could help out there.
We are using it in a few projects and I noticed that I could not get rid of the many duplicated deps and wondered why.
btcd's main package isn't really meant for outside usage, each of the individual packages are.
Why not? It's a perfectly usable library. I make use of the wire package a lot to parse Bitcoin transactions, or use the txscript package for various things. These are not nested modules either - what is the benefit of having btcutil being a nested module?
Nested modules are kind of confusing and seem hard to maintain anyway, seems more natural to just make it a package - would there be a downside to that?
Why not? It's a perfectly usable library. I make use of the
wirepackage a lot to parse Bitcoin transactions, or use thetxscriptpackage for various things. These are not nested modules either - what is the benefit of having btcutil being a nested module?
Not much besides that it's just been like that.
Nested modules are kind of confusing and seem hard to maintain anyway, seems more natural to just make it a package - would there be a downside to that?
Not that I can think of.
Clean this up when releasing v0.25 pls