Navigation Menu

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: support for spaces or URL encoded spaces in git URL #37556

Closed
mbrancato opened this issue Feb 28, 2020 · 5 comments
Closed

cmd/go: support for spaces or URL encoded spaces in git URL #37556

mbrancato opened this issue Feb 28, 2020 · 5 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@mbrancato
Copy link

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

$ go version
go version go1.14 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

What did you do?

go get "dev.azure.com/org/Project Name/_git/reponame"
go get "dev.azure.com/org/Project%20Name/_git/reponame"

What did you expect to see?

Azure DevOps supports go get but go get does not support spaces or HTTP encoded spaces (which is what most tools use to get around this).

What did you see instead?

invalid char '%'

and

invalid char ' '

@mbrancato mbrancato changed the title cmd/go: support for spaces or HTTP encoded spaces in git URL cmd/go: support for spaces or URL encoded spaces in git URL Feb 28, 2020
@jayconrod
Copy link
Contributor

Could clarify if this is about spaces in repository URLs or package paths?

Arguments to go get are package paths. Given a package path, go get finds the repository URL by sending a request to https://example.com/pkg?go-get=1 (for package example.com/pkg), then looking for a go-import meta tag. Remote import paths has more info.

I think spaces in repository URLs are already allowed. I don't know of any reason they should be rejected, so if they're not working, we should fix that.

It sounds like this is more about allowing spaces in package paths though. golang.org/x/mod/module.CheckImportPath describes the current limitations.

CheckImportPath checks that an import path is valid.

A valid import path consists of one or more valid path elements separated by slashes (U+002F). (It must not begin with nor end in a slash.)

A valid path element is a non-empty string made up of ASCII letters, ASCII digits, and limited ASCII punctuation: + - . _ and ~. It must not begin or end with a dot (U+002E), nor contain two dots in a row.

The element prefix up to the first dot must not be a reserved file name on Windows, regardless of case (CON, com1, NuL, and so on).

CheckImportPath may be less restrictive in the future, but see the top-level package documentation for additional information about subtleties of Unicode.

@jayconrod jayconrod added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 28, 2020
@mbrancato
Copy link
Author

Hi @jayconrod

This is about spaces in the git repo URL, AFAIK. In my example above I forgot to add that I'm using the .git extension.

go get "dev.azure.com/org/Project%20Name/_git/reponame.git" / go get "dev.azure.com/org/Project Name/_git/reponame.git" this is all part of the repo URL, not any sub packages.

$ go get "dev.azure.com/org/Project Name/_git/reponame.git"
go get dev.azure.com/org/Project Name/_git/reponame.git: malformed module path "dev.azure.com/org/Project Name/_git/reponame.git": invalid char ' '

@bcmills
Copy link
Contributor

bcmills commented Mar 3, 2020

@mbrancato, the argument to go get is a package path, not a URL.

The package path often corresponds to the URL, but they are separate entities. (The .git extension is one mechanism the go tool uses to convert between the two, but it is by no means the only way.)

@bcmills
Copy link
Contributor

bcmills commented Mar 3, 2020

Given that there are straightforward workarounds (either choose a project name without spaces, or set up a go-import HTTPS server that can resolve a spaceless path to a URL-encoded repo URL), I think the usability benefits of rejecting spaces in package paths still outweigh the flexibility of allowing spaces in package paths.

@jayconrod
Copy link
Contributor

@mbrancato Your examples reference package paths on the command line. Repository URLs won't appear on the command line or in .go files; they'll only show up in <meta go-import ...> tags, as described in Remove import paths.

As an example of how this is typically set up, consider the module golang.org/x/mod. In order to locate its repository, go get sends a GET request to https://golang.org/x/mod?go-get=1. The server responds with HTML containing the following tag:

<meta name="go-import" content="golang.org/x/mod git https://go.googlesource.com/mod">

From that, go get learns that it should clone the repository https://go.googlesource.com/mod.


I believe spaces are already supported in repository URLs, but if you find that's not the case, please give an example where it's not working.

I'm not convinced spaces should be allowed in module and package paths. Package paths use a limited set of characters for clarity and simplicity. If the underlying repository URL has spaces, that's okay, but the package path will need to be different from the repository URL.

@golang golang locked and limited conversation to collaborators Mar 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants