vc60er / deptree

show golang dependence like tree
76 stars 9 forks source link

wrong upgrade suggestions for higher go versions #14

Open gen2thomas opened 1 year ago

gen2thomas commented 1 year ago

for a go application with go version 1.19 this suggestion was done by deptree: github.com/stretchr/testify@v1.8.2 (go1.13) => [v1.8.3]

testify 1.8.2 is a go 1.13 module, but v1.8.3 is a go 1.20 module

the go versions are listed correctly for both modules:

go list -m -json github.com/stretchr/testify@v1.8.2
{
    "Path": "github.com/stretchr/testify",
    "Version": "v1.8.2",
    "Time": "2023-02-25T12:46:30Z",
    "Dir": "/home/user/go/pkg/mod/github.com/stretchr/testify@v1.8.2",
    "GoMod": "/home/user/go/pkg/mod/cache/download/github.com/stretchr/testify/@v/v1.8.2.mod",
    "GoVersion": "1.13",
    "Origin": {
        "VCS": "git",
        "URL": "https://github.com/stretchr/testify",
        "Ref": "refs/tags/v1.8.2",
        "Hash": "f36bfe3c337aa95c86f04c721acdbafb5ffb1611"
    }
}

testify v1.8.3:

go list -m -json github.com/stretchr/testify@latest
{
    "Path": "github.com/stretchr/testify",
    "Version": "v1.8.3",
    "Query": "latest",
    "Time": "2023-05-10T21:42:04Z",
    "Dir": "/home/user/go/pkg/mod/github.com/stretchr/testify@v1.8.3",
    "GoMod": "/home/user/go/pkg/mod/cache/download/github.com/stretchr/testify/@v/v1.8.3.mod",
    "GoVersion": "1.20",
    "Origin": {
        "VCS": "git",
        "URL": "https://github.com/stretchr/testify",
        "Ref": "refs/tags/v1.8.3",
        "Hash": "4c93d8f201cb46ed50de949ee65804f944b570f8"
    }
}

But the same call for upgrade do not contain the go version element:

go list -u -m -json github.com/stretchr/testify@v1.8.2
{
    "Path": "github.com/stretchr/testify",
    "Version": "v1.8.2",
    "Time": "2023-02-25T12:46:30Z",
    "Update": {
        "Path": "github.com/stretchr/testify",
        "Version": "v1.8.3",
        "Time": "2023-05-10T21:42:04Z"
    },
    "Dir": "/home/user/go/pkg/mod/github.com/stretchr/testify@v1.8.2",
    "GoMod": "/home/user/go/pkg/mod/cache/download/github.com/stretchr/testify/@v/v1.8.2.mod",
    "GoVersion": "1.13",
    "Origin": {
        "VCS": "git",
        "URL": "https://github.com/stretchr/testify",
        "Ref": "refs/tags/v1.8.2",
        "Hash": "f36bfe3c337aa95c86f04c721acdbafb5ffb1611"
    }
}
gen2thomas commented 1 year ago

according to man page, the json element should normally contain a pointer to the module, so it should contain the go version, but it don't:

type Module struct {
...
  Update     *Module       // available update (with -u)
...
   GoVersion  string        // go version used in module
}

Possible Solution: