News for hackers. Stuff that matters.
Re:Examples of beautiful Go? by pjmlp on Thursday March 14, 2013 @02:28PM (#5376767)
If this is refactoring, then you never used a proper IDE with refactoring support.

Slide 5 is the proof this is no better than search and replace.

Re:Examples of beautiful Go? by NateDad on Thursday March 14, 2013 @02:51PM (#5376916)
Honestly, that's not a very good representation of what gofmt can do.

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:]

Re:Examples of beautiful Go? by danieldk on Thursday March 14, 2013 @03:48PM (#5377257)
True, it's much more than simple search and replace, since it produces an AST, which provides more powerful refactoring.

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 ;).

Re:Examples of beautiful Go? by chimeracoder on Thursday March 14, 2013 @03:25PM (#5377088)
Also, a regex will replace matching strings in incorrect places (like a string literal that happens to contain Go code).

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.