:execute
is for built-in Ex commands, you want the :!
command to execute an external command:
:!go install
It appears that the 'makeprg'
option would be beneficial here, too. Compilation is such a frequent task that vi / Vim have a trigger mechanism built-in. If you
:set makeprg=go
you can trigger the build with :make install
.
To change to the current directory, either use
:cd %:h
or (to always to this automatically):
:set autochdir