goreportcard
goreportcard copied to clipboard
Check failed for repo with major versions defined as first line in go.mod
My repo defines v3 major version in go.mod file Refresh button click failed with error
There was an error processing your request: Could not analyze the repository: could not download repo: could not get latest module version from https://proxy.golang.org/github.com/ydb-platform/ydb-go-sdk/@latest: not found: module github.com/ydb-platform/ydb-go-sdk: no matching versions for query "latest"
Also I try to call curl command and receive the same result:
curl --request POST -d "repo=github.com/ydb-platform/ydb-go-sdk/v3" https://goreportcard.com/checks
Could not analyze the repository: could not download repo: could not get latest module version from https://proxy.golang.org/github.com/ydb-platform/ydb-go-sdk/@latest: not found: module github.com/ydb-platform/ydb-go-sdk: no matching versions for query "latest
How to refresh repository report for major versions?
same issue, any solutions?
The problem seems to be in https://github.com/gojp/goreportcard/blob/fe7635329954dfcb646a25072c24228494537881/handlers/check.go#L24. The call to Download.Clean
returns base url of the module and this url has the version /v*
suffix stripped.
For example github.com/ydb-platform/ydb-go-sdk/v3
will be transformed to github.com/ydb-platform/ydb-go-sdk
and it will call https://proxy.golang.org/github.com/ydb-platform/ydb-go-sdk/@latest
instead of https://proxy.golang.org/github.com/ydb-platform/ydb-go-sdk/v3/@latest
. And this returns the error.
I think the fact that v2 or later major versions of module are included in the path is a recent development that the code doesn't seem to take into account.
I could do a hotfix and use a regex to check if the base path is followed by /vX
(where x >= 2) and not to strip that part. (Or does anyone know how go get
does it?)
This fix may be broke repositories where v2+ versions stored as subdirectory of repo
- if use wget/curl download instead go get
If goreportcard use
go get
- your fix is ok
This fix may be broke repositories where v2+ versions stored as subdirectory of repo
It should work, the goreportcard code uses Module Proxy protocol (see $base/$module/@v/$version.info
docu) to download the .zip of the repository. The Module Proxy does the resolution whether v2+ is stored in the repo root or in subdirectory. We just need the correct module name for all this to work.
The whole fix should thus consist of updating download.Clean
not to strip v2+ from the url submitted by user. (If I find the time, I might open PR with the change before the end of the week.)