Move go detection and environment setup into its own function

@jbeda please take a look.

This should fix the Vagrant issue.

Cheers,
Filipe