Which, btw, gofmt does does pattern replacement.
http://talks.godoc.org/github.com/sunfmin/talks/2013/gofmt.s...
Slide 5 is the proof this is no better than search and replace.
This is a much better example: http://research.swtch.com/gofmt
gofmt -w -r 'x[i:len(x)] -> x[i:]' *.go
Note that this is not a regular expression... it's looking for go expressions that match that pattern.
So, for example, this will catch this:
a := charts[start:len(charts)]
and convert it to this:
a := charts[start:]
It's also not very spectacular, since it's what Java IDEs have done for ages, plus incremental compiling :). (Or code analysis tools such as Sonatype.) Go is just playing catch-up here.
The one thing they did very well is dictating the code style with gofmt. You may not like it, but at least there is once standard. Though, one wonders how many developers and businesses use whatever layout Eclipse or Netbeans use out of the box ;).
You can design your regex around this, but at some point, you'll end up just reinventing a Go parser inside a hideous, unmaintainable regex. So you might as well just use gofmt.
Combined with structural regular expressions you can answer questions like "what are the types that contain both a mutex and a map, and what are the types that contain the types that use a map without a mutex": http://pastebin.ca/2202690
Coming from a background in Lisp, I don't find much in Go that seems very 'elegant' or 'beautiful'. What I find is that everything - including the Go source code itself - is perfectly standardized (and therefore immediately readable).
I don't have to worry about different coding styles, about semicolons vs. no semicolons[0], about having more than one way to express the same code. I can skim the code easily because the structure is so uniform across all standard and community libraries.
That's a different kind of beauty from chaining macros and cons cells, but it's beautiful nonetheless.
[0]https://github.com/twitter/bootstrap/issues/3057