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/go2go: Having a _test.go2 file that is alphabetically first makes the package unimportable #39851

Closed
argusdusty opened this issue Jun 25, 2020 · 2 comments

Comments

@argusdusty
Copy link

@argusdusty argusdusty commented Jun 25, 2020

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

C:\Users\argusdusty\Code\src\foo>go version
go version devel +4dfbf5ab9c Thu Jun 25 02:57:14 2020 +0000 windows/amd64

Does this issue reproduce with the latest release?

reproduces with 4dfbf5a

What operating system and processor architecture are you using (go env)?

go env Output
C:\Users\argusdusty\Code\src\foo>go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\argusdusty\AppData\Local\go-build
set GOENV=C:\Users\argusdusty\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\argusdusty\Code\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\argusdusty\Code
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Gosrc
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Gosrc\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ARGUSD~1\AppData\Local\Temp\go-build897251974=/tmp/go-build -gno-record-gcc-switches

What did you do?

foo/lib/a_test.go2:

package lib

foo/lib/lib.go2:

package lib

func Func() {
	println("Hello, World!")
}

foo/foo.go2:

import "foo/lib"

func main() {
	lib.Func()
}

C:\Users\argusdusty\Code\src\foo>go tool go2go build

What did you expect to see?

Successful compilation.

What did you see instead?

.\foo.go2:7: undefined: lib.Importable୦

Renaming a_test.go2 to lib_test.go2 resolves the issue and builds/runs successfully. Viewing the generated .go files shows type Importable୦ int is being placed in the alphabetically first file, even if that is a _test.go file.

This can also be replicated by attempting to import "github.com/argusdusty/sort2" which has export_test.go2 as the alphabetically first file.

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 25, 2020

Change https://golang.org/cl/240004 mentions this issue: [dev.go2go] go/go2go: don't add importable name to test file

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 25, 2020

Thanks. This is now fixed on the dev.go2go branch.

gopherbot pushed a commit that referenced this issue Jun 25, 2020
No test case because we will don't have a general test harness.

Fixes #39851

Change-Id: If7b1262404f390eba80d53c2c1d40724252a5833
Reviewed-on: https://go-review.googlesource.com/c/go/+/240004
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.