4 ms·
One recent use of the Go parsing and printing packages is goimports, a tool that automatically adds and removes import statements based on the code you've writt
by enneff 13y ago
One recent use of the Go parsing and printing packages is goimports, a tool that automatically adds and removes import statements based on the code you've written.
Try loading this snippet, checking the "Import" box, and clicking "Format": http://play.golang.org/p/jS4s_Xz26v http://play.golang.org/p/jS4s_Xz26v
To use it locally:
$ go get code.google.com/p/go.tools/cmd/goimports
- Intermernet 13y agoI was on play.golang.org last night and didn't see that button. When did that get added? That's brilliant!
- enneff 13y agoWe added it this week. :-)
- moomin 13y agoClojure has Slamhound. Yeah, I know you didn't want to hear about LISP...
- vanderZwan 13y agoennef is not charlieflowers (in fact he is Andrew Gerrand, one of the official Go devs).
- charlieflowers 13y agoPlus, I love Lisp! It even has a lot of the characteristics that would allow what I'm talking about. I was just trying to articulate that what I'm saying requires more than just SEXP's and Lisp macros (although that does go a long way). And Slamhound is definitely barking up the same tree. Very interesting!
- moomin 13y agoYeah, SEXPs and LISP macros to a full refactor aware environment is like getting to Riemann surfaces from set theory.* *The small problem with this example is that in fact the latter has been achieved.
- charlieflowers 13y agoI suspect that this is a very clever joke. And possibly that I might be the butt of the joke. But I suspect that even so, the joke is so good that I'd still laugh heartily at it. Unfortunately, I freely admit that the joke goes right over my head. I used to know something about Riemann surfaces, so I could invest some time and eventually get the joke perhaps, but I just don't have time now. :)
- moomin 13y agoSorry, the chain is just Set Theory Natural Numbers Integers Rationals Real Numbers Complex Numbers Calculus Riemann Surfaces (as the Apple ads say, some steps skipped) The only point I was making was that the level you were thinking at was much higher than the level SEXPs are at. Trying to envisage how we get there remains hard. TL;DR I was agreeing with you. :)
- charlieflowers 13y agoI haven't delved into Go, but have occasionally "glanced" at it with curiosity. One of the most powerful principles I got a whiff of was that it was designed up front with the goal of providing a powerful tool chain -- an open parsing library and the like. That provides some incredible power and may be the thing about Go that impresses me the most. What if we also made programming language decisions about syntax, modularity constructs, etc., all with that goal in mind? (And perhaps Go has to a large degree).
- axaxs 13y agoCan this become part of Gofmt triggered by a flag? I love it, and feel it should really be part of an installation.
- enneff 13y agoGoimports is a fork of gofmt, so you can use it as a drop-in replacement. We're considering whether to merge the functionality back into gofmt. Goimports is still pretty experimental, so this might not happen until Go 1.4, if it does at all.