Skip to content

Commit

Permalink
update some for issue template
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Dec 29, 2020
1 parent 30a8334 commit 1b37255
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Expand Up @@ -7,7 +7,14 @@ assignees: inhere

---

**System (please complete the following information):**

- OS: `linux` [e.g. linux, macOS]
- GO Version: `1.13` [e.g. `1.13`]
- Pkg Version: `1.1.1` [e.g. `1.1.1`]

**Describe the bug**

A clear and concise description of what the bug is.

**To Reproduce**
Expand All @@ -17,15 +24,13 @@ A clear and concise description of what the bug is.
```

**Expected behavior**

A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**System (please complete the following information):**
- OS: [e.g. Linux]
- GO version [e.g. 1.13]
- Pkg Version [e.g. 1.1.1]
If applicable, add screenshots to help explain your problem.

**Additional context**

Add any other context about the problem here.
21 changes: 21 additions & 0 deletions fsutil/filesystem.go
Expand Up @@ -31,6 +31,10 @@ var (
}
)

// var (
// ReadFile = ioutil.ReadFile
// )

// FileExists reports whether the named file or directory exists.
// Deprecated
// please use PathExists() or IsFile() instead it
Expand Down Expand Up @@ -86,6 +90,23 @@ func Mkdir(dirPath string, perm os.FileMode) error {
return os.MkdirAll(dirPath, perm)
}

// OpenFile like os.OpenFile, but will auto create dir.
func OpenFile(filepath string, flag int, mode int) (*os.File, error) {
fileDir := path.Dir(filepath)

// if err := os.Mkdir(dir, 0777); err != nil {
if err := os.MkdirAll(fileDir, 0777); err != nil {
return nil, err
}

file, err := os.OpenFile(filepath, flag, os.FileMode(mode))
if err != nil {
return nil, err
}

return file, nil
}

// CreateFile if not exists
// Usage:
// CreateFile("path/to/file.txt", 0664, 0666)
Expand Down

0 comments on commit 1b37255

Please sign in to comment.