Skip to content

x/tools/cmd/stringer: does no longer work in package with uninstalled dependencies #31216

Closed
@eliaperantoni

Description

@eliaperantoni

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

$ go version
go version go1.11.4 windows/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
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Elia\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Elia\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\Elia\AppData\Local\Temp\go-build407096830=/tmp/go-build -gno-record-gcc-switches

What did you do?

Ran stringer -type MyType in the package where struct MyType is declared.

What did you expect to see?

stringer running correctly and producing a generated code file like it always did so far

What did you see instead?

This error

PS C:\Users\Elia\go\src\gitlab.com\eliaperantoni\helloworld> stringer -type MyType
stringer: go [list -e -json -compiled=true -test=false -export=false -deps=true -find=false -tags= -- .]: exit status 1: go build github.com/sirupsen/logrus: no Go files in
go build github.com/goburrow/modbus: no Go files in

It seems like stringer is no longer able to operate when searching for a type declaration in a package that has uninstalled dependencies like it did before.

Installing dependencies before running stringer makes it work correctly.

Why would anyone need this?

I'm building docker images for my go application that doesn't use any dependency managment tool yet. The build process:

  1. Installs some essential dependencies like stringer itself
  2. Runs go generate
  3. Then installs all dependencies using go get -d ./.... Because of this there's no need to update the Dockerfile after adding or removing dependencies.

Running go generate before go get -d ./...is necessary because otherwise some directories would end up having no go files, causing go get to fail.

When was it working?

I've manually installed a version of golang.org/x/tools that goes back to the first week of march 2019 and that one works without any problems. It seems like golang.org/x/tools/go/packages has been updated ever since (while golang.org/x/tools/cmd/stringer hasn't) but I can't pinpoint the line or commit that is causing the issue.

Maybe this is even some intentional behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions