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: module tool failures for delve #38272

Closed
cfiderer opened this issue Apr 6, 2020 · 1 comment
Closed

cmd/go: module tool failures for delve #38272

cfiderer opened this issue Apr 6, 2020 · 1 comment

Comments

@cfiderer
Copy link

cfiderer commented Apr 6, 2020

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

$ go version
go version go1.14.1 linux/amd64

also tried with go version go1.14 windows/amd64
file1.zip

`

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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/cfradm/.cache/go-build"
GOENV="/home/cfradm/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/cfradm/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/mnt/c/SAPDevelop/git/slplugin/src/git.wdf.sap.corp/tools/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build045342322=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I work in an environment that requires vendoring.

I try to vendor the tools we need for building and testing, starting with stringer (golang.org/x/tools/cmd/stringer), esc (github.com/mjibson/esc) and dlv (github.com/go-delve/delve/cmd/dlv) using the recipes from issue #25922 .

Installing the tools with go install is fine, all modules are available locally.

stringer and esc work like a breeze, but delve has several issues:

  • After installing with go install github.com/go-delve/delve/cmd/dlv, go.mod and go.sum have entries for delve:
$ grep delve *
go.mod: github.com/go-delve/delve v1.4.0 // indirect
go.sum:github.com/go-delve/delve v1.4.0 h1:O+1dw1XBZXqhC6fIPQwGxLlbd2wDRau7NxNhVpw02ag=
go.sum:github.com/go-delve/delve v1.4.0/go.mod h1:gQM0ReOJLNAvPuKAXfjHngtE93C2yc/ekTbo7YbAHSo=
tools.go://go:generate go install -mod=vendor github.com/go-delve/delve/cmd/dlv
tools.go:       _ "github.com/go-delve/delve"
$
  • When I run go mod vendor, I end up with a failure:
$ go mod vendor
go: finding module for package github.com/go-delve/delve
git.wdf.sap.corp/tools imports
        github.com/go-delve/delve: module github.com/go-delve/delve@latest found (v1.4.0), but does not contain package github.com/go-delve/delve
$

Running go mod tidy purges the delve-related entries from go.mod and go.sum.

What did you expect to see?

go mod tidy retains / the references to github.com/go-delve/delve and its dependencies
go mod vendor provides all delve-related modules in the vendor subdirectory.

What did you see instead?

When I run go mod vendor, I end up with a failure:

$ go mod vendor
go: finding module for package github.com/go-delve/delve
git.wdf.sap.corp/tools imports
        github.com/go-delve/delve: module github.com/go-delve/delve@latest found (v1.4.0), but does not contain package github.com/go-delve/delve
$

The vendor subdirectory lacks github.com/go-delve/delve.

Running go mod tidy purges the delve-related entries from go.mod and go.sum.

@jayconrod
Copy link
Contributor

From the error message, it sounds like you have a tools.go file like this (containing other imports, too):

// +build tools

package tools

import _ "github.com/go-delve/delve"

The error is happening because github.com/go-delve/delve is not a package path, only a module path.

Instead, tools.go should import the main packages for each needed executable.

// +build tools

package tools

import _ "github.com/go-delve/delve/cmd/dlv"

Normally, importing a main package is an error, but the tools package never gets built. It's just there so go mod tidy doesn't remove requirements.


Closing this issue because it doesn't seem to be a bug in cmd/go. Gophers Slack (for this topic, the #modules channel) and the go-nuts mailing lists are better places for troubleshooting.

@golang golang locked and limited conversation to collaborators Apr 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants