gorename with main packages

157 views
Skip to first unread message

Konstantin Cherkasoff

unread,
Apr 5, 2015, 7:21:34 PM4/5/15
to golan...@googlegroups.com
Hi All!
How to specify -from for gorename to rename an object in main package if I have several mains (in different directories) in my GOPATH ?

src/app1/main.go << there is package main 
src/app2/main.go << there is package main too

I need to rename type Foo to Bar in app2.

$ gorename -from ... ?


Can you provide an example for me?

adon...@google.com

unread,
Apr 6, 2015, 4:55:34 PM4/6/15
to golan...@googlegroups.com
% go get golang.org/x/tools/cmd/gorename

% head -n8 $GOPATH/src/golang.org/x/tools/cmd/gorename/main.go
// The gorename command performs precise type-safe renaming of
// identifiers in Go source code.
//
// Run with -help for usage information, or view the Usage constant in
// package golang.org/x/tools/refactor/rename, which contains most of
// the implementation.
//
package main // import "golang.org/x/tools/cmd/gorename"

% gorename -from '"golang.org/x/tools/cmd/gorename".offsetFlag' -to offsetFlag2
Renamed 3 occurrences in 1 file in 1 package.
Reply all
Reply to author
Forward
0 new messages