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

No go files in package: when running go run with vendor folder #33240

Closed
coderste opened this issue Jul 23, 2019 · 3 comments
Closed

No go files in package: when running go run with vendor folder #33240

coderste opened this issue Jul 23, 2019 · 3 comments

Comments

@coderste
Copy link

coderste commented Jul 23, 2019

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

$ go version
go version go1.12.6 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
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/shi03/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/shi03/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.6/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.6/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/shi03/code/projects/gs/common-api/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/dc/pxx2c5t503jdfy7c29qrlmp9nkvqm9/T/go-build575521762=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I have a file with

//go:generate go run github.com/99designs/gqlgen

At the top which will run a package to generate some files for me. I'm running all this within a docker container using Go Mods but it's in vendor mode.

Inside the docker container I have GOFLAGS=-mod=vendor to run all commands by using the vendor folder

The issues here lies with when I try to run go generate ./... inside the docker container. It returns the error:

package github.com/99designs/gqlgen: no Go files in /code/project/vendor/github.com/99designs/gqlgen

I'm assuming when the go generate -mod=vendor ./... command tries to run go run -mod=vendor github.com/99designs/gqlgen it can't find no Go files within the package.

What did you expect to see?

I expected for the go run command to work when vendoring packages.

What did you see instead?

The command didn't work it just returned:

package github.com/99designs/gqlgen: no Go files in /code/project/vendor/github.com/99designs/gqlgen

@coderste coderste changed the title No go files in: when running go run with vendor folder No go files in package: when running go run with vendor folder Jul 23, 2019
@coderste
Copy link
Author

I believe this relates to #27227

@bcmills
Copy link
Contributor

bcmills commented Jul 23, 2019

Per https://blog.golang.org/generate:

if the containing package is intended for import by go get, once the file is generated (and tested!) it must be checked into the source code repository to be available to clients.

go mod vendor vendors in only those packages that are needed to build (using go build) and test (using go test) the packages in the main module. So it is expected that go generate does not work in general with -mod=vendor.

@bcmills
Copy link
Contributor

bcmills commented Jul 23, 2019

Duplicate of #29516

@bcmills bcmills marked this as a duplicate of #29516 Jul 23, 2019
@bcmills bcmills closed this as completed Jul 23, 2019
@golang golang locked and limited conversation to collaborators Jul 22, 2020
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