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

cmd/go: `go mod download -json` is incomplete #29772

Open
Stebalien opened this issue Jan 16, 2019 · 2 comments

Comments

@Stebalien
Copy link

commented Jan 16, 2019

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

$ go version
go version go1.11.4 linux/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
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/steb/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/steb/projects/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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=/run/user/1000/tmp/go-build023848120=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. Ran go mod download -json.
  2. Bundled up all files listed in the JSON output (adding /list files as needed).
  3. Tried to replay this bundle, using an HTTP server as a GOPROXY.

What did you expect to see?

go build, go mod download should work without fetching anything.

What did you see instead?

go build and go mod download is getting 404 errors due to files missing from the bundle. It looks like go build is trying to fetch:

  1. Packages mentioned in go.sum files that aren't actually needed for the build (as far as I can tell, at least).
  2. Older (minor) versions of packages mentioned in some dependencies' go.mod files.

I'd expect go mod download -json to return a list of every downloaded package.


Context: I'm trying to integrate go mod with IPFS.

Testing against: https://github.com/anacrolix/torrent/tree/ipgo

@oiooj oiooj added the modules label Jan 17, 2019

@Stebalien

This comment has been minimized.

Copy link
Author

commented Jan 17, 2019

It looks like go mod download -json returns all the modules with code needed to build the current package. However, go needs some metadata from all modules mentioned in go mod graph.

Options as I see them:

  1. Allow go build and friends to work when this metadata is unavailable. Given that go doesn't appear to need the code, this should be possible as far as I can tell.
  2. Include required metadata in the output of go mod download -json. That is, return Module structs with the Zip field omitted.
  3. Update the documentation for go mod download -json.

@bcmills bcmills changed the title `go mod download -json` is incomplete cmd/go: `go mod download -json` is incomplete Jan 18, 2019

@bcmills

This comment has been minimized.

Copy link
Member

commented Jan 22, 2019

go build isn't trying to fetch anything extra based on the contents of go.sum, but it is trying to fetch go.mod files for all of the module versions that appear in the requirements of any module in the module graph.

Probably we should download those go.mod files in go mod download and include them in the -json output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.