If you want to see the chain of module that explains why a package is reachable from a module, use go mod why
package main
import (
"database/sql"
_ "modernc.org/sqlite"
)
func main() {
db, err := sql.Open("sqlite", "::")
if err != nil {
panic(err)
}
_ = db.Close()
}
Here, we see that the chain that leads from the sqlite to hashicorp module.
go mod why -m github.com/hashicorp/golang-lru/v2
# github.com/hashicorp/golang-lru/v2
go1
modernc.org/sqlite
modernc.org/libc
modernc.org/libc.test
modernc.org/ccgo/v4/lib
modernc.org/ccgo/v4/lib/internal/secret_sauce
modernc.org/gc/v3
github.com/hashicorp/golang-lru/v2