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: import paths can contain the .test suffix, breaking the toolchain #60454

Open
dominikh opened this issue May 26, 2023 · 6 comments
Open
Labels
GoCommand cmd/go help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dominikh
Copy link
Member

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

$ go version
go version devel go1.21-231f290e51 Sat Apr 8 05:25:04 2023 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

Given

-- foo/foo.go --
package foo

import _ "example.com/foo.test"
-- foo/foo_test.go --
package foo
-- foo.test/bar.go --
package bar
-- go.mod --
module example.com

go 1.21

run go test ./foo

What did you expect to see?

One of

  • no error
  • an explanation for the error
  • an explicit error forbidding using foo.test as an import path

What did you see instead?

/home/dominikh/prj/go/pkg/tool/linux_amd64/link: fingerprint mismatch: example.com/foo.test has 36b962da8ceb542c, import from example.com/foo expecting aa419b4c2ff8e5ed
@mvdan
Copy link
Member

mvdan commented May 26, 2023

an explicit error forbidding using foo.test as an import path

This would be my personal choice - even if supporting such package paths is technically possible, it feels like something we should strongly discourage due to the confusion it could cause.

We always have to worry about backwards compatibility, but... is anyone even declaring such packages today?

@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels May 26, 2023
@bcmills bcmills added this to the Backlog milestone May 26, 2023
@bcmills
Copy link
Contributor

bcmills commented May 26, 2023

(CC @matloob)

@egonelbre
Copy link
Contributor

an explicit error forbidding using foo.test as an import path

This would be my personal choice - even if supporting such package paths is technically possible, it feels like something we should strongly discourage due to the confusion it could cause.

We always have to worry about backwards compatibility, but... is anyone even declaring such packages today?

I've been using .test modules (note, not packages per se) for writing examples or tests, because that TLD is guaranteed not to exist (https://en.wikipedia.org/wiki/.test). But, it's also possible to .example or .invalid as an alternative.

@mvdan
Copy link
Member

mvdan commented May 26, 2023

@egonelbre you can just name those test/..., per #37641.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/513655 mentions this issue: cmd/go: reject import paths with suffix .test

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/613399 mentions this issue: cmd/go: reject import paths with suffix .test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants