Cleaned up the build/build.go script

This is a small cleanup of the file used for building the collector, the following changes have been made:

1. Only open the main.go file once

2. File AST scanning loop now uses less type-switches, for a single
case these are not worth it.

3. Moved the BasicLit type-assertion outside the cases, this means
we only have to do it once in the code.

4. Cleaned up the writing of the edited file, this now uses a
go/printer.Config with the same options as go/format currently does.
This allows us to write a correctly formatted file straight away.

I believe these changes make the file more maintainable than before.