Quick Go Hack - Renaming Structs

Today I found myself needing to rename a struct throughout the codebase of a project. In many languages, doing this would either require some perl/sed kung-fu or an IDE tool like you'd find in IntelliJ. Go, however, comes with a handly tool for doing this: gofmt. That's right, it does more than just fix your whitespace.

Here's the command I issued to re-name my struct:

gofmt -r 'GlobalAttributes -> HTML' -w ./

In a nutshell, this looks for the name GlobalAttributes and...

 •  0 comments  •  flag
Share on Twitter
Published on September 26, 2015 11:47
No comments have been added yet.