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: build incorrectly uses build tag go1.8 with go versions other than go1.8 when using vendored dependencies #24303

Closed
pmalek opened this issue Mar 7, 2018 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@pmalek
Copy link

pmalek commented Mar 7, 2018

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

go version go1.10 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/USER/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/USER/.gvm/pkgsets/go1.10/global"
GORACE=""
GOROOT="/home/USER/.gvm/gos/go1.10"
GOTMPDIR=""
GOTOOLDIR="/home/USER/.gvm/gos/go1.10/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=/tmp/go-build674906758=/tmp/go-build -gno-record-gcc-switches

What did you do?

By using a sample application which uses firebase SDK (https://firebase.google.com/docs/admin/setup)

package main

import (
	"context"
	"log"

	firebase "firebase.google.com/go"
)

func main() {
	if _, err := firebase.NewApp(context.Background(), nil); err != nil {
		log.Fatalf("error initializing app: %v", err)
	}
}

it builds when using dependecies fetched with go get ... but when put in vendor/ directory it breaks

go build
# github.com/pmalek/firebase_dep/vendor/google.golang.org/api/transport/grpc
vendor/google.golang.org/api/transport/grpc/go18.go:25:45: undefined: ocgrpc.ClientHandler

Sample application with vendored out dependencies (using https://github.com/golang/dep) can be found at https://github.com/pmalek/firebase_no_dep

For reasons unknown to me even with build tag

// +build go1.8

the file vendor/google.golang.org/api/transport/grpc/go18.go builds with go1.10 (tested also on go1.9 and the results are the same)

What did you expect to see?

App builds with dependencies fetched with go get and with those put in vendor/ dir.

What did you see instead?

go build
# github.com/pmalek/firebase_dep/vendor/google.golang.org/api/transport/grpc
vendor/google.golang.org/api/transport/grpc/go18.go:25:45: undefined: ocgrpc.ClientHandler
@pmalek pmalek changed the title Build incorrectly uses build tags go1.8 with other go versions than go1.8 when used with vendored dependecies Build incorrectly uses build tags go1.8 with go versions than go1.8 when used with vendored dependecies Mar 7, 2018
@pmalek pmalek changed the title Build incorrectly uses build tags go1.8 with go versions than go1.8 when used with vendored dependecies Build incorrectly uses build tag go1.8 with go versions than go1.8 when used with vendored dependecies Mar 7, 2018
@andybons andybons changed the title Build incorrectly uses build tag go1.8 with go versions than go1.8 when used with vendored dependecies cmd/go: build incorrectly uses build tag go1.8 with go versions other than go1.8 when using vendored dependencies Mar 7, 2018
@andybons
Copy link
Member

andybons commented Mar 7, 2018

/cc @rsc @ianlancetaylor

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 7, 2018
@andybons andybons added this to the Go1.11 milestone Mar 7, 2018
@ianlancetaylor
Copy link
Contributor

Go 1.10 will builds files with the go1.0, go1.1, go1.2, ..., go1.8, go1.9, go1.10 build tags. The go1.8 build tag doesn't mean "only build with Go 1.8". It means "build with any version of Go that supports Go 1.8." To build with only Go 1.8 you need to write, for example, // +build go1.8 !go1.9.

Closing because I don't think there is anything to do. Please comment if I misunderstood.

@pmalek
Copy link
Author

pmalek commented Mar 7, 2018

@ianlancetaylor that is clear.

It seems the problem was for me that I have had slightly newer version in GOPATH which was building successfully and in some way I got slightly older dependecies in vendor dir which were not building.

Resolved and thanks for explanation!

@golang golang locked and limited conversation to collaborators Mar 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants