Similar to what you changed below, I think this could be:

```go
if fi, err := os.Stat(hkpath); err == nil && fi.IsDir() {
  return hkpath
}
```