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: reject module path beginning with slash #28389

Open
rsc opened this Issue Oct 25, 2018 · 3 comments

Comments

Projects
None yet
5 participants
@rsc
Copy link
Contributor

rsc commented Oct 25, 2018

Re #28336, we should

  1. Reject go mod init /absolute/path.
  2. Refuse to load any go.mod that says module /absolute/path.

If we'd done either of those (we should do both), then the confusing build errors in #28336 would not have happened.

@rsc rsc added this to the Go1.12 milestone Oct 25, 2018

@tandr

This comment has been minimized.

Copy link

tandr commented Oct 25, 2018

To me it seems that denying full path in mod init would be counterproductive for people willing (or have no choice but) to specify a full path because thats how they have their build system set up

I would not be surprised to see this in a bootstrap script

go mod init /bigdisk/buildmount/$USER/$REPO/some/path

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Jan 17, 2019

@bcmills bcmills added the modules label Jan 17, 2019

@jayconrod

This comment has been minimized.

Copy link
Contributor

jayconrod commented Feb 26, 2019

For reference, cmd/go/internal/module.CheckPath is the function go get uses to validate module paths. It performs a number of checks, not just for leading slashes.

In tests, I think we're using module paths that don't satisfy this check (e.g., the module path is a single word without a .). It's likely other people are taking advantage of this as well, both in tests and in monorepos that are never fetched with go get.

@wselwood

This comment has been minimized.

Copy link
Contributor

wselwood commented Feb 27, 2019

Trailing slashes should probably also be blocked. It works as long as you don't have sub packages. As soon as you try to import a sub package you get errors like
build github.com/satappscatapult/warmconsidering/: cannot find module for path github.com/satappscatapult/warmconsidering/message

which is mighty confusing

series of comands

go mod init github.com/satelliteapplicationscatapult/warmconsidering/
code .
# write some things and create a submodule
go build
build github.com/satappscatapult/warmconsidering/: cannot find module for path github.com/satappscatapult/warmconsidering/message

edit the go.mod file to remove the trailing slash from the build starts to work as expected.

@bcmills bcmills self-assigned this Feb 27, 2019

@bcmills bcmills added the NeedsFix label Feb 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.