golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.34k stars 17.7k forks source link

cmd/go: reject leading dot in module name #66954

Open Mgrdich opened 7 months ago

Mgrdich commented 7 months ago

Go version

go1.22.1

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/mgo/Library/Caches/go-build'
GOENV='/Users/mgo/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/mgo/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/mgo/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/mgo/sdk/go1.22.1'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/mgo/sdk/go1.22.1/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/mgo/Documents/testGoApi/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/dn/076kyhqn5knf9lgnb0v9m5980000gn/T/go-build2843189004=/tmp/go-build -gno-record-gcc-switches -fno-common

What did you do?

It is happening when everything is in different folder , and initiated with different packages , that is why i cannot link go.dev/play

but i can link the github repo with a branch that this is happening

https://github.com/Mgrdich/testGoApi/tree/bug/issue/golang

https://github.com/Mgrdich/testGoApi/blob/fd329312a1472c5d3c5269f792a438d999e43829/internal/routes/person.go#L18

https://github.com/Mgrdich/testGoApi/blob/fd329312a1472c5d3c5269f792a438d999e43829/internal/middlewares/movies.go#L28

https://github.com/Mgrdich/testGoApi/blob/fd329312a1472c5d3c5269f792a438d999e43829/internal/middlewares/id_context.go#L14

What did you see happen?

i keep getting this compile time error

panic: R_USEIFACE in .com/internal/middlewares..dict.CheckSlugId[.com/internal/models.Person] references type:.com/internal/util.GetByIDFunc[.com/internal/models.Person] which is not a type or itab

goroutine 1 [running]:
cmd/link/internal/ld.(*deadcodePass).flood(0x14000026910)
    cmd/link/internal/ld/deadcode.go:208 +0xfd4
cmd/link/internal/ld.deadcode(0x1400015e000)
    cmd/link/internal/ld/deadcode.go:433 +0x58
cmd/link/internal/ld.Main(_, {0x10, 0x20, 0x1, 0x1f, 0x1e, 0x7c00000, {0x0, 0x0, 0x0}, ...})
    cmd/link/internal/ld/main.go:353 +0x1180
main.main()
    cmd/link/main.go:72 +0xbd4

as i noticed it is happening something with the folder and package structure

What did you expect to see?

It return the correct error , with description that module name is invalid.

seankhliao commented 7 months ago

I don't think that's a valid module name (.com). Seems to work if you change it to something more normal.

Mgrdich commented 7 months ago

it works when i change the module name , even though it was working some of the time , but giving issues alot of the other times.

jfrech commented 7 months ago

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.
  • (...)
  • A path element may not begin or end with a dot (., U+002E).

(...)

Cf. https://go.dev/ref/mod#go-mod-file-ident [2024-04-27]

Mgrdich commented 7 months ago

yes @jfrech but shouldn't the compiler return the correct error , instead of R_USEIFACE in which is not a type or itab

jfrech commented 7 months ago

@Mgrdich I am all for less obtuse failure diagnostics. Yet you wrote "What did you expect to see? ; It should compile the project and produce the executable.", which is behaviour which violates the modules specification.

Mgrdich commented 7 months ago

@jfrech my bad , I did not know back then it was a module name issue , I will change what do I expect .