mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 16:10:59 +08:00
refactor: 重构 tools.Remove 函数
This commit is contained in:
@@ -31,13 +31,8 @@ func Read(path string) (string, error) {
|
||||
}
|
||||
|
||||
// Remove 删除文件/目录
|
||||
// TODO 重构带 error 返回
|
||||
func Remove(path string) bool {
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
func Remove(path string) error {
|
||||
return os.RemoveAll(path)
|
||||
}
|
||||
|
||||
// Exec 执行 shell 命令
|
||||
|
||||
@@ -46,7 +46,7 @@ func (s *SystemHelperTestSuite) TestRemove() {
|
||||
err := os.WriteFile(filePath, []byte("test data"), 0644)
|
||||
s.Nil(err)
|
||||
|
||||
s.True(Remove(filePath))
|
||||
s.Nil(Remove(filePath))
|
||||
}
|
||||
|
||||
func (s *SystemHelperTestSuite) TestExec() {
|
||||
|
||||
Reference in New Issue
Block a user