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 error with vendored golang.org/x/net/idna #32784

Closed
jomenxiao opened this issue Jun 26, 2019 · 4 comments
Closed

cmd/go: build error with vendored golang.org/x/net/idna #32784

jomenxiao opened this issue Jun 26, 2019 · 4 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@jomenxiao
Copy link

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

$ go version
go version go1.12.4 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/jomenxiao/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/jomenxiao/go"
GOPROXY="https://goproxy.io"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.4/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/4r/glj9yz5j181b2lrzg3rgqtsmjh_07s/T/go-build542760379=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

the vendor directory is generated by GO111MODULE=on go mod vendor
and try to build it with error

GO111MODULE=on CGO_ENABLED=0 go build -mod=vendor  -o bin/cd cmd/main.go
# golang.org/x/net/idna
vendor/golang.org/x/net/idna/idna10.0.0.go:46:6: ToASCII redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:44:33
vendor/golang.org/x/net/idna/idna10.0.0.go:51:6: ToUnicode redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:49:35
vendor/golang.org/x/net/idna/idna10.0.0.go:56:6: Option redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:54:6
vendor/golang.org/x/net/idna/idna10.0.0.go:63:6: Transitional redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:61:38
vendor/golang.org/x/net/idna/idna10.0.0.go:69:6: VerifyDNSLength redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:67:35
vendor/golang.org/x/net/idna/idna10.0.0.go:78:6: RemoveLeadingDots redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:76:37
vendor/golang.org/x/net/idna/idna10.0.0.go:85:6: ValidateLabels redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:83:34
vendor/golang.org/x/net/idna/idna10.0.0.go:106:6: StrictDomainName redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:104:33
vendor/golang.org/x/net/idna/idna10.0.0.go:119:6: BidiRule redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:117:17
vendor/golang.org/x/net/idna/idna10.0.0.go:125:6: ValidateForRegistration redeclared in this block
	previous declaration at vendor/golang.org/x/net/idna/idna.go:123:32
vendor/golang.org/x/net/idna/idna10.0.0.go:125:6: too many errors

What did you expect to see?

hope gomod support dependent package's with multiple version

What did you see instead?

GO111MODULE=on go build -mod=vendor main.go
can not support dependent package's with multiple version

@jomenxiao jomenxiao changed the title support dependent package's with multiple version when use mod=vendor flag gomod support dependent package's with multiple version when use mod=vendor flag Jun 26, 2019
@bcmills
Copy link
Contributor

bcmills commented Jun 27, 2019

I'm unable to reproduce the problem using go1.12.6. I suspect that it has something to do with the contents of your main.go; if you're still having this problem, please provide a source file and specific sequence of go commands that reproduces it.

example.com$ go1.12.6 mod init example.com
go: creating new go.mod: module example.com

example.com$ go1.12.6 get -d golang.org/x/net
go: finding golang.org/x/net latest
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding golang.org/x/text v0.3.0
go: downloading golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: extracting golang.org/x/net v0.0.0-20190620200207-3b0461eec859

example.com$ cat > main.go
package main

import _ "golang.org/x/net/idna"

func main() {}

example.com$ go1.12.6 mod vendor
go: downloading golang.org/x/text v0.3.0
go: extracting golang.org/x/text v0.3.0

example.com$ CGO_ENABLED=0 go1.12.6 build -mod=vendor main.go

example.com$

@bcmills bcmills changed the title gomod support dependent package's with multiple version when use mod=vendor flag cmd/go: build error with vendored golang.org/x/net/idna Jun 27, 2019
@bcmills bcmills added modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jun 27, 2019
@bcmills
Copy link
Contributor

bcmills commented Jun 27, 2019

As far as I can tell, there is no point in history that includes idna10.0.0.go and idna.go simultaneously, so I'm especially curious to see the sequence of commands that resulted in both files existing in the vendor directory.

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jun 27, 2019
@jomenxiao
Copy link
Author

sorry,
I can not reproduce it today.
and can not find idna10.0.0.go and idna.go all existed in path vendor/golang.org/x/net/idna

the sequence of commands

  1. GO111MODULE=on go mod vendor on a host(in US)
  2. tar -zcvf $GOPATH/src/github.com/xxx/xxx the directory to another host(in China)
  3. GO111MODULE=on go mod vendor on another host(in China), and command failed some times.
  4. GO111MODULE=on CGO_ENABLED=0 go build -mod=vendor -o bin/cd cmd/main.go on another host(in China)

@bcmills bcmills removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 1, 2019
@bcmills
Copy link
Contributor

bcmills commented Jul 1, 2019

Thanks. Without a concrete procedure to reproduce the issue or a pattern of similar failures, I don't think we would be able to verify a diagnosis or a fix, so I'm going to close this issue.

If you see it again, please do file a new issue with whatever new details you can add.

@bcmills bcmills closed this as completed Jul 1, 2019
@golang golang locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules 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

3 participants