今まで golang で変数名や関数名のリネームには gofmt の -r オプションを使ってきましたが、これからは gorename を使いましょう。 文法を解析して正しくリネームしてくれるので、gofmt で起き得た誤爆も心配ありません。インストールは以下の様に実行します。 $ go get golang.org/x/tools/cmd/gorename 使用方法は以下の通り。 gorename: precise type-safe renaming of identifiers in Go source code. Usage: gorename (-from <spec> | -offset <file>:#<byte-offset>) -to <name> [-force] You must specify the object (named entity) to rename
![Big Sky :: golang のリファクタリングには gofmt ではなく、gorename を使おう。](https://cdn-ak-scissors.b.st-hatena.com/image/square/ae5f360d3c82cd87e23b34fb6f5013ab7cf0f1a6/height=288;version=1;width=512/https%3A%2F%2Fmattn.kaoriya.net%2Fimages%2Flogo.png)