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: malformed import path error for paths with plus sign in go1.16 #45158

Closed
siadat opened this issue Mar 22, 2021 · 2 comments
Closed

cmd/go: malformed import path error for paths with plus sign in go1.16 #45158

siadat opened this issue Mar 22, 2021 · 2 comments

Comments

@siadat
Copy link
Contributor

siadat commented Mar 22, 2021

Go 1.15 used to compile package names with + signs in them, however, in Go 1.16 I get an error (tested on both macOS and Linux).

What version of Go are you using?

$ go version # darwin
go version go1.16.2 darwin/amd64

$ go version # linux
go version go1.16.2 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

Let's create 3 files:

// go.mod
module github.com/siadat/a+b
go 1.16
// x/x.go
package x

type X int
// y/y.go
package y

import "github.com/siadat/a+b/x"

type X x.X

Then
go build ./...

What did you expect to see?

No errors

What did you see instead?

malformed import path "github.com/siadat/a+b/x": invalid char '+'
malformed import path "github.com/siadat/a+b/y": invalid char '+'
@AlexRouSg
Copy link
Contributor

AlexRouSg commented Mar 22, 2021

Duplicate of #44776
Backport issue for 1.16 is #44885

You can try with tip to see if the patch works.

EDIT: The above only applies to packages within the module.
Modules cannot have a + in the name as per https://golang.org/ref/mod#go-mod-file-ident

A module path must satisfy the following requirements:

  • The path must consist of one or more path elements separated by slashes (/, U+002F). It must not begin or end with a slash.
  • Each path element is a non-empty string made of up ASCII letters, ASCII digits, and limited ASCII punctuation (-, ., _, and ~).
  • A path element may not begin or end with a dot (., U+002E).
  • 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).

@jayconrod jayconrod changed the title malformed import path error for paths with plus sign in go1.16 cmd/go: malformed import path error for paths with plus sign in go1.16 Mar 22, 2021
@jayconrod
Copy link
Contributor

Closing as duplicate, per @AlexRouSg's comment. This should be fixed in 1.16.3.

+ is not allowed in module paths, but the main module and replaced modules may break some of the rules, which I think is the case here.

@golang golang locked and limited conversation to collaborators Mar 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants