Ack. This is copied from the code I added to gofmt. Your trick probably works, but files are simple.