Skip to content

Commit

Permalink
ADD: osutil DefaultFileMode & DefaultDirMode
Browse files Browse the repository at this point in the history
  • Loading branch information
whoisnian committed Apr 20, 2023
1 parent 1480c39 commit 313652c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions util/osutil/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"os"
)

const (
DefaultFileMode os.FileMode = 0644
DefaultDirMode os.FileMode = 0755
)

// CopyFile reads data from source file and writes to target file.
// If the target file already exists, it is overwritten.
func CopyFile(srcPath, destPath string) (int64, error) {
Expand Down
2 changes: 1 addition & 1 deletion util/osutil/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestCopyFile(t *testing.T) {
srcPath := filepath.Join(tempDir, "src")
destPath := filepath.Join(tempDir, "dest")

err = os.WriteFile(srcPath, want, 0644)
err = os.WriteFile(srcPath, want, osutil.DefaultFileMode)
if err != nil {
t.Fatalf("WriteFile: %v", err)
}
Expand Down

0 comments on commit 313652c

Please sign in to comment.