Skip to content

proposal: cmd/go: add module repository health check tool #28590

@myitcv

Description

@myitcv

What version of Go are you using (go version)?

$ go version
go version go1.11.1 linux/amd64

Does this issue reproduce with the latest release?

n/a

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPROXY=""
GORACE=""
GOROOT="/home/myitcv/gos"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build925002674=/tmp/go-build -gno-record-gcc-switches"

Details

A number of issues and Slack and go-nuts questions boil down to a VCS repository being in some way "invalid" as far as modules are concerned. An incomplete list includes:

  • go.mod for a v >= 2 module not having a /v2 suffix
  • tags that are not semver compatible
  • go.mod incomplete (i.e. the result of go mod tidy not committed)
  • transitive dependencies leaking through to the main module because a dependency's go.mod is not complete
  • Whether a version is compatible with Go pre 1.9.7 or 1.10.3
  • ...

I think it might be useful to develop a tool that can be run against an arbitrary (remote) VCS repository that catches these sorts of problems, but also provides a summary of what is valid. A health check if you will.

This would be a tool for authors as well as consumers, because indicating (perhaps via one of those GitHub README badges) that your repository is module-safe is a good state and signal. Indeed in time this might be something that would sit well on godoc.org/similar, but in the short term a command line tool would have significant value.

These checks could of course be heavily cached (somewhere central).

This is a very rough idea, so just posting for thoughts/feedback:

$ modanalyse https://github.com/myitcv/terrible
Results for https://github.com/myitcv/terrible:

Semver issues:
    0.0.1 is not compatible with Go modules; should be v0.0.1
    0.0.1alpha is not a valid pre-release

Module completeness:
    v0.0.3 is missing a go.sum
    v0.0.4 has an incomplete go.mod

Invalid releases:
    v2.0.0 invalid because go.mod does not end with /v2

Valid releases:
    v0.0.2
    v1.0.0
    v2.0.1

cc @rsc @bcmills @thepudds @rogpeppe @mvdan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions