🆕为实现数据迁移以及备份新增配置导出

This commit is contained in:
coward
2024-09-20 17:26:41 +08:00
parent c3ef51e87f
commit edaf9ba770
11 changed files with 247 additions and 3 deletions

28
utils/file.go Normal file
View File

@@ -0,0 +1,28 @@
package utils
import (
"fmt"
"os"
)
type fileUtils struct{}
func FileUtils() fileUtils {
return fileUtils{}
}
// GenerateFile
// @description: 生成文件
// @receiver fileUtils
// @param filename 文件名称
// @param content 文件内容
// @return error
func (fileUtils) GenerateFile(filename string, content []byte) (filepath string, err error) {
path := "/tmp/"
if os.Getenv("GIN_MODE") != "release" {
path = "E:\\Workspace\\Go\\wireguard-ui\\template\\tmp\\"
}
filepath = fmt.Sprintf("%s%s", path, filename)
err = os.WriteFile(filepath, content, 0777)
return filepath, err
}