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

x/tools/cmd/gomvpkg: should also rewrite package name in external tests #10507

Closed
minux opened this issue Apr 20, 2015 · 5 comments
Closed

x/tools/cmd/gomvpkg: should also rewrite package name in external tests #10507

minux opened this issue Apr 20, 2015 · 5 comments

Comments

@minux
Copy link
Member

minux commented Apr 20, 2015

By external test, I mean package pkgname_test

the pkgname part should also be updated to the new package name, otherwise
go build/install will complain.

BTW, external tests also tend to use dot import to import the package under
test, even though we don't support fixing dot imports now, ideally we should
support this special case.

One test case is to move golang.org/x/tools/types to golang.org/x/tools/gotypes.

@minux minux added this to the Go1.5Maybe milestone Apr 20, 2015
@minux
Copy link
Member Author

minux commented Apr 20, 2015

I understand refactor/rename can't generally support dot imports, but
I think supporting dot import in context of moving package import paths
should be straightforward. Or am I missing anything?

@rsc rsc modified the milestones: Unreleased, Go1.5Maybe Apr 26, 2015
@davidrjenni
Copy link
Contributor

I came up with a change, which should fixes the issue.
Given the command gomvpkg -from foo -to bar, the following files:

// $GOPATH/src/foo/foo.go
package foo
type T int
// $GOPATH/src/foo/foo_test.go
package foo_test
import "foo"
var _ foo.T
// $GOPATH/src/baz/baz_test.go
package baz_test
import "foo"
var _ foo.T

are now rewritten to

// $GOPATH/src/bar/bar.go
package bar
type T int
// $GOPATH/src/bar/bar_test.go
package bar_test
import "bar"
var _ bar.T
// $GOPATH/src/baz/baz_test.go
package baz_test
import "bar"
var _ bar.T

Can I send the change for further review?

@ianlancetaylor
Copy link
Contributor

@davidrjenni Please contribute changes using the process described at https://golang.org/doc/contribute.html . Thanks.

@davidrjenni
Copy link
Contributor

I sent a CL: https://golang.org/cl/12637

@davidrjenni
Copy link
Contributor

This was fixed in golang/tools@20d85c3.
I guess the issue can be closed.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
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

6 participants