Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: cmd/go: add repo info to go list -m -json #42746

Closed
psantos1113 opened this issue Nov 20, 2020 · 7 comments
Closed

proposal: cmd/go: add repo info to go list -m -json #42746

psantos1113 opened this issue Nov 20, 2020 · 7 comments
Labels
FrozenDueToAge GoCommand cmd/go Proposal WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@psantos1113
Copy link

When executing the command go list -m -u -json all having the root repository path and sub-module directory information would be useful in determining where exactly a module came from.
This would help determining where it was downloaded from and what tag was used to get the correct version of the module to debug any issues related to the module.
In the go module documentation there is the following example:

<meta name="go-import" content="golang.org/x/mod git https://go.googlesource.com/mod"

If the module imports golang.org/x/mod you would think that it is downloading the module from https://golang.org exactly.
Based on the result of the go-get query in the example, the repository where the module is downloaded from is https://go.googlesource.com/mod
This illustrates that the repository URL could be different.

Since go already calculates the repository root path and the submodule directory to obtain modules internally within go, I am proposing two additional fields to be added to the module data.
"RepositoryRootPath": "",
"ModuleSubdirectory": ""

Always show the RepositoryRootPath for all modules when listing them.
If the module is located in a subdirectory of the root repository, then add the ModuleSubdirectory to the output of the module.

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

$ go version
go version go1.15.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/user-1/Library/Caches/go-build"
GOENV="/Users/user-1/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/user-1/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/user-1/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/user-1/go/azure-autorest-test/src/go.mod"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/s7/pngnf4m90m3gxp02xxpm5wkh0000gn/T/go-build227528808=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I created a sample module that imports modules that are in a subdirectory of a root repository.

main.go

package main

import (
    "fmt"
    "github.com/Azure/go-autorest/autorest"
    "github.com/Azure/go-autorest/autorest/azure"
    "github.com/Azure/go-autorest/autorest/validation"
    "github.com/Azure/go-autorest/autorest/to"
)

func main() {
    fmt.Println("Hello repository with subdirectory modules test!");
}

go.mod

module example.com/submodule-test

go 1.15

require (
	github.com/Azure/go-autorest/autorest v0.11.11
	github.com/Azure/go-autorest/autorest/to v0.4.0
	github.com/Azure/go-autorest/autorest/validation v0.3.0
)

What did you expect to see?

go list -m -u -json all Output:
{
	"Path": "example.com/submodule-test",
	"Main": true,
	"Dir": "/Users/user-1/go/submodule-test/src",
	"GoMod": "/Users/user-1/go/submodule-test/src/go.mod",
	"GoVersion": "1.15"
}
{
	"Path": "github.com/Azure/go-autorest",
        "RepositoryRootPath": "github.com/Azure/go-autorest",
	"Version": "v14.2.0+incompatible",
	"Time": "2020-06-23T16:10:07Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest@v14.2.0+incompatible",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/@v/v14.2.0+incompatible.mod"
}
{
	"Path": "github.com/Azure/go-autorest/autorest",
        "RepositoryRootPath": "github.com/Azure/go-autorest",
        "ModuleSubdirectory": "autorest",
	"Version": "v0.11.11",
	"Time": "2020-11-09T22:22:39Z",
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest@v0.11.11",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/@v/v0.11.11.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/adal",
        "RepositoryRootPath": "github.com/Azure/go-autorest",
        "ModuleSubdirectory": "autorest/adal",
	"Version": "v0.9.5",
	"Time": "2020-10-06T19:19:20Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/adal@v0.9.5",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/adal/@v/v0.9.5.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/date",
        "RepositoryRootPath": "github.com/Azure/go-autorest",
        "ModuleSubdirectory": "autorest/date",
	"Version": "v0.3.0",
	"Time": "2020-06-23T18:36:26Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/date@v0.3.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/date/@v/v0.3.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/mocks",
        "RepositoryRootPath": "github.com/Azure/go-autorest",
        "ModuleSubdirectory": "autorest/mocks",
	"Version": "v0.4.1",
	"Time": "2020-08-13T18:36:39Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/mocks@v0.4.1",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/mocks/@v/v0.4.1.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/to",
        "RepositoryRootPath": "github.com/Azure/go-autorest",
        "ModuleSubdirectory": "autorest/to",
	"Version": "v0.4.0",
	"Time": "2020-06-23T18:36:26Z",
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/to@v0.4.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/to/@v/v0.4.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/validation",
        "RepositoryRootPath": "github.com/Azure/go-autorest",
        "ModuleSubdirectory": "autorest/validation",
	"Version": "v0.3.0",
	"Time": "2020-06-23T18:36:26Z",
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/validation@v0.3.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/validation/@v/v0.3.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/logger",
        "RepositoryRootPath": "github.com/Azure/go-autorest",
        "ModuleSubdirectory": "logger",
	"Version": "v0.2.0",
	"Time": "2020-06-23T18:36:26Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/logger@v0.2.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/logger/@v/v0.2.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/tracing",
        "RepositoryRootPath": "github.com/Azure/go-autorest",
        "ModuleSubdirectory": "tracing",
	"Version": "v0.6.0",
	"Time": "2020-06-23T18:36:26Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/tracing@v0.6.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/tracing/@v/v0.6.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/davecgh/go-spew",
        "RepositoryRootPath": "github.com/davecgh/go-spew",
	"Version": "v1.1.0",
	"Time": "2016-10-29T20:57:26Z",
	"Update": {
		"Path": "github.com/davecgh/go-spew",
		"Version": "v1.1.1",
		"Time": "2018-02-21T23:26:28Z"
	},
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/davecgh/go-spew@v1.1.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/davecgh/go-spew/@v/v1.1.0.mod"
}
{
	"Path": "github.com/form3tech-oss/jwt-go",
        "RepositoryRootPath": "github.com/form3tech-oss/jwt-go",
	"Version": "v3.2.2+incompatible",
	"Time": "2020-09-15T13:53:29Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/form3tech-oss/jwt-go@v3.2.2+incompatible",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/form3tech-oss/jwt-go/@v/v3.2.2+incompatible.mod"
}
{
	"Path": "github.com/pmezard/go-difflib",
    "RepositoryRootPath": "github.com/pmezard/go-difflib",
	"Version": "v1.0.0",
	"Time": "2016-01-10T10:55:54Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/pmezard/go-difflib@v1.0.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/pmezard/go-difflib/@v/v1.0.0.mod"
}
{
	"Path": "github.com/stretchr/objx",
        "RepositoryRootPath": "github.com/stretchr/objx",
	"Version": "v0.1.0",
	"Time": "2018-01-06T01:13:53Z",
	"Update": {
		"Path": "github.com/stretchr/objx",
		"Version": "v0.3.0",
		"Time": "2019-04-15T11:18:23Z"
	},
	"Indirect": true,
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/stretchr/objx/@v/v0.1.0.mod"
}
{
	"Path": "github.com/stretchr/testify",
        "RepositoryRootPath": "github.com/stretchr/testify",
	"Version": "v1.3.0",
	"Time": "2019-01-03T19:31:39Z",
	"Update": {
		"Path": "github.com/stretchr/testify",
		"Version": "v1.6.1",
		"Time": "2020-06-05T10:48:45Z"
	},
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/stretchr/testify@v1.3.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/stretchr/testify/@v/v1.3.0.mod"
}
{
	"Path": "golang.org/x/crypto",
        "RepositoryRootPath": "go.googlesource.com/crypto",
	"Version": "v0.0.0-20201002170205-7f63de1d35b0",
	"Time": "2020-10-02T17:02:05Z",
	"Update": {
		"Path": "golang.org/x/crypto",
		"Version": "v0.0.0-20201117144127-c1f2f97bffc9",
		"Time": "2020-11-17T14:41:27Z"
	},
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/golang.org/x/crypto@v0.0.0-20201002170205-7f63de1d35b0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/golang.org/x/crypto/@v/v0.0.0-20201002170205-7f63de1d35b0.mod",
	"GoVersion": "1.11"
}
{
	"Path": "golang.org/x/net",
        "RepositoryRootPath": "go.googlesource.com/net",
	"Version": "v0.0.0-20190404232315-eb5bcb51f2a3",
	"Time": "2019-04-04T23:23:15Z",
	"Update": {
		"Path": "golang.org/x/net",
		"Version": "v0.0.0-20201110031124-69a78807bb2b",
		"Time": "2020-11-10T03:11:24Z"
	},
	"Indirect": true,
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/golang.org/x/net/@v/v0.0.0-20190404232315-eb5bcb51f2a3.mod"
}
{
	"Path": "golang.org/x/sys",
        "RepositoryRootPath": "go.googlesource.com/sys",
	"Version": "v0.0.0-20190412213103-97732733099d",
	"Time": "2019-04-12T21:31:03Z",
	"Update": {
		"Path": "golang.org/x/sys",
		"Version": "v0.0.0-20201119102817-f84b799fce68",
		"Time": "2020-11-19T10:28:17Z"
	},
	"Indirect": true,
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/golang.org/x/sys/@v/v0.0.0-20190412213103-97732733099d.mod",
	"GoVersion": "1.12"
}
{
	"Path": "golang.org/x/text",
        "RepositoryRootPath": "go.googlesource.com/text",
	"Version": "v0.3.0",
	"Time": "2017-12-14T13:08:43Z",
	"Update": {
		"Path": "golang.org/x/text",
		"Version": "v0.3.4",
		"Time": "2020-10-21T14:53:29Z"
	},
	"Indirect": true,
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/golang.org/x/text/@v/v0.3.0.mod"
}

What did you see instead?

go list -m -u -json all

go list -m -u -json all Output
{
	"Path": "example.com/azure-test",
	"Main": true,
	"Dir": "/Users/user-1/go/azure-autorest-test/src",
	"GoMod": "/Users/user-1/go/azure-autorest-test/src/go.mod",
	"GoVersion": "1.15"
}
{
	"Path": "github.com/Azure/go-autorest",
	"Version": "v14.2.0+incompatible",
	"Time": "2020-06-23T16:10:07Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest@v14.2.0+incompatible",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/@v/v14.2.0+incompatible.mod"
}
{
	"Path": "github.com/Azure/go-autorest/autorest",
	"Version": "v0.11.11",
	"Time": "2020-11-09T22:22:39Z",
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest@v0.11.11",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/@v/v0.11.11.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/adal",
	"Version": "v0.9.5",
	"Time": "2020-10-06T19:19:20Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/adal@v0.9.5",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/adal/@v/v0.9.5.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/date",
	"Version": "v0.3.0",
	"Time": "2020-06-23T18:36:26Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/date@v0.3.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/date/@v/v0.3.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/mocks",
	"Version": "v0.4.1",
	"Time": "2020-08-13T18:36:39Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/mocks@v0.4.1",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/mocks/@v/v0.4.1.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/to",
	"Version": "v0.4.0",
	"Time": "2020-06-23T18:36:26Z",
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/to@v0.4.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/to/@v/v0.4.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/autorest/validation",
	"Version": "v0.3.0",
	"Time": "2020-06-23T18:36:26Z",
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/autorest/validation@v0.3.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/autorest/validation/@v/v0.3.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/logger",
	"Version": "v0.2.0",
	"Time": "2020-06-23T18:36:26Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/logger@v0.2.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/logger/@v/v0.2.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/Azure/go-autorest/tracing",
	"Version": "v0.6.0",
	"Time": "2020-06-23T18:36:26Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/!azure/go-autorest/tracing@v0.6.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/!azure/go-autorest/tracing/@v/v0.6.0.mod",
	"GoVersion": "1.12"
}
{
	"Path": "github.com/davecgh/go-spew",
	"Version": "v1.1.0",
	"Time": "2016-10-29T20:57:26Z",
	"Update": {
		"Path": "github.com/davecgh/go-spew",
		"Version": "v1.1.1",
		"Time": "2018-02-21T23:26:28Z"
	},
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/davecgh/go-spew@v1.1.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/davecgh/go-spew/@v/v1.1.0.mod"
}
{
	"Path": "github.com/form3tech-oss/jwt-go",
	"Version": "v3.2.2+incompatible",
	"Time": "2020-09-15T13:53:29Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/form3tech-oss/jwt-go@v3.2.2+incompatible",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/form3tech-oss/jwt-go/@v/v3.2.2+incompatible.mod"
}
{
	"Path": "github.com/pmezard/go-difflib",
	"Version": "v1.0.0",
	"Time": "2016-01-10T10:55:54Z",
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/pmezard/go-difflib@v1.0.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/pmezard/go-difflib/@v/v1.0.0.mod"
}
{
	"Path": "github.com/stretchr/objx",
	"Version": "v0.1.0",
	"Time": "2018-01-06T01:13:53Z",
	"Update": {
		"Path": "github.com/stretchr/objx",
		"Version": "v0.3.0",
		"Time": "2019-04-15T11:18:23Z"
	},
	"Indirect": true,
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/stretchr/objx/@v/v0.1.0.mod"
}
{
	"Path": "github.com/stretchr/testify",
	"Version": "v1.3.0",
	"Time": "2019-01-03T19:31:39Z",
	"Update": {
		"Path": "github.com/stretchr/testify",
		"Version": "v1.6.1",
		"Time": "2020-06-05T10:48:45Z"
	},
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/github.com/stretchr/testify@v1.3.0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/github.com/stretchr/testify/@v/v1.3.0.mod"
}
{
	"Path": "golang.org/x/crypto",
	"Version": "v0.0.0-20201002170205-7f63de1d35b0",
	"Time": "2020-10-02T17:02:05Z",
	"Update": {
		"Path": "golang.org/x/crypto",
		"Version": "v0.0.0-20201117144127-c1f2f97bffc9",
		"Time": "2020-11-17T14:41:27Z"
	},
	"Indirect": true,
	"Dir": "/Users/user-1/go/pkg/mod/golang.org/x/crypto@v0.0.0-20201002170205-7f63de1d35b0",
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/golang.org/x/crypto/@v/v0.0.0-20201002170205-7f63de1d35b0.mod",
	"GoVersion": "1.11"
}
{
	"Path": "golang.org/x/net",
	"Version": "v0.0.0-20190404232315-eb5bcb51f2a3",
	"Time": "2019-04-04T23:23:15Z",
	"Update": {
		"Path": "golang.org/x/net",
		"Version": "v0.0.0-20201110031124-69a78807bb2b",
		"Time": "2020-11-10T03:11:24Z"
	},
	"Indirect": true,
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/golang.org/x/net/@v/v0.0.0-20190404232315-eb5bcb51f2a3.mod"
}
{
	"Path": "golang.org/x/sys",
	"Version": "v0.0.0-20190412213103-97732733099d",
	"Time": "2019-04-12T21:31:03Z",
	"Update": {
		"Path": "golang.org/x/sys",
		"Version": "v0.0.0-20201119102817-f84b799fce68",
		"Time": "2020-11-19T10:28:17Z"
	},
	"Indirect": true,
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/golang.org/x/sys/@v/v0.0.0-20190412213103-97732733099d.mod",
	"GoVersion": "1.12"
}
{
	"Path": "golang.org/x/text",
	"Version": "v0.3.0",
	"Time": "2017-12-14T13:08:43Z",
	"Update": {
		"Path": "golang.org/x/text",
		"Version": "v0.3.4",
		"Time": "2020-10-21T14:53:29Z"
	},
	"Indirect": true,
	"GoMod": "/Users/user-1/go/pkg/mod/cache/download/golang.org/x/text/@v/v0.3.0.mod"
}
@psantos1113 psantos1113 changed the title Add repository root path and module subdirectory when listing modules with go list -m -json Proposal: Add repository root path and module subdirectory when listing modules with go list -m -json Nov 20, 2020
@gopherbot gopherbot added this to the Proposal milestone Nov 20, 2020
@psantos1113 psantos1113 changed the title Proposal: Add repository root path and module subdirectory when listing modules with go list -m -json proposal: Add repository root path and module subdirectory when listing modules with go list -m -json Nov 20, 2020
@seankhliao
Copy link
Member

The go command may not have this information if it only communicates with a proxy. Additionally this information is not guaranteed to be stable over time since code host can change, or even available.

@mvdan
Copy link
Member

mvdan commented Nov 23, 2020

If people really want this, there could be a (likely third party) tool to work it out from the output of go list -m. I've thought about it in the past, but not implemented it yet. Beware that, like @seankhliao says, it's a best-effort reconstruction since Go modules are decoupled from VCS servers/systems.

Nested or overlapping modules also make this reconstruction work much trickier than it might seem.

@ianlancetaylor ianlancetaylor added the GoCommand cmd/go label Jan 6, 2021
@rsc
Copy link
Contributor

rsc commented Jul 14, 2021

This doesn't seem viable to me. The default Go config is to use the proxy, which does not serve this information. Making go list -m -json do additional repo work would slow it down, to provide info that very few use cases need. As others noted, we have worked very hard to completely separate modules from the underlying repos.

Doing this in a separate package makes more sense. (It need not be a standard or golang.org/x package.)

@rsc rsc changed the title proposal: Add repository root path and module subdirectory when listing modules with go list -m -json proposal: cmd/go: add repo info to go list -m -json Jul 14, 2021
@bcmills
Copy link
Contributor

bcmills commented Aug 2, 2021

The .info files served by proxies could theoretically report this information (where they already record the original commit timestamp).

It would be somewhat analogous to the “downloaded on…” citations you sometimes see in research papers that cite websites: it would tell you where the proxy got its copy of the module from, but the module wouldn't necessarily still be available from that source.

@seankhliao
Copy link
Member

I remember filing #44742 for having the info recorded in the .info files

@dmitshur
Copy link
Contributor

Is this resolved by the "Origin" JSON key added to the output of go list -json -m (and go mod download -json) in Go 1.19? (See #53644, CL 411397, https://pkg.go.dev/cmd/go#hdr-List_packages_or_modules, and #44742 (comment).)

Example
$ go list -m -json golang.org/x/mod@latest
{
	[...]
	"Origin": {
		"VCS": "git",
		"URL": "https://go.googlesource.com/mod",
		"Ref": "refs/tags/v0.10.0",
		"Hash": "ad6fd61f94f8fdf6926f5dee6e45bdd13add2f9f"
	}
}

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 15, 2023
@gopherbot
Copy link
Contributor

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2023
@golang golang locked and limited conversation to collaborators Jun 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go Proposal WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

8 participants