golang / go

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

x/tools/cmd/gorename: unsure how to use -from to specify renaming test #34659

Closed nnathan closed 3 weeks ago

nnathan commented 5 years ago

What did you do?

Created a simple package "foo" in $GOPATH/src/foo with a single go file foo_test.go:

package foo_test
const testVal = 5 // note letter t in testVal starts at byte 25

I can successfully rename testVal using the -offset option:

gorename -v -d -offset foo_test.go:#27 -to blah

However I cannot seem to use the -from option because it fails to find the package:

$ gorename -from '"foo_test".testVal' -to blah
gorename: can't find package "foo_test"

What did you expect to see?

I expect to see gorename succeed when using -from on a test package.

I've tried a foo.go containing similar code under package foo, and renaming the symbol using gorename -from is fine.

I'm not sure if I need to specify some kind of testing build tag using the -tags option to get it to examine test packages.

gopherbot commented 4 years ago

Change https://golang.org/cl/211957 mentions this issue: refactor/rename: add renaming for packages ends with test

seankhliao commented 3 weeks ago

closing as obsoleted by #69360