You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/08/07 14:10:44 UTC
[GitHub] [rocketmq-client-go] pangliang opened a new pull request #145:
[ISSUE #123] Fix nil pointer when file not exist
pangliang opened a new pull request #145: [ISSUE #123] Fix nil pointer when file not exist
URL: https://github.com/apache/rocketmq-client-go/pull/145
```go
func MakeFileIfNotExist(path string) error {
//when path is not exist, info: nil err: error | *os.PathError
info, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
if err = os.MkdirAll(path, 0755); err != nil {
return err
}
}
}
// info still nil after mkdir
if !info.IsDir() {
return errors.New(path + " is a file")
}
return nil
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services