It is dangerous to ignore the error result from os.RemoveAll in the defer.  Ideally, the full command would fail if the  tmpDir could not be removed, but logging the error at the minimum would be a good idea, something like this:

```go
defer func(d string) {
    if err := os.RemoveAll(d); err != nil {
        logf("error removing TempDir %v: %v", d, err)
    }
}(tmpDir)
```

Note that if you really want to change the return value of this entire function, then you would probably have to incorporate a named return value, but for this particular case, I think that is more pain than it is worth.