Are you running this in your editor context, or in a container perhaps? It won't work in a context without the GOPATH env variable set.
If running with go run main.go, does it work? It works for me in that context without modifying your code. As long as the parent context has access to GOPATH it should. You could alternatively set it manually with something like this:
command.Env = append(os.Environ(), "GOPATH=/tmp/go")
Or you could set GOPATH (for install) and PATH (for go,git cmds) in the context this process will run in (probably preferable), for example in a systemd unit file.