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 }