package dbHelper import ( "io" "log" "os" "strings" ) type FileSaveHelper struct { Directory string FilenameExtension string } func (the *FileSaveHelper) Initial() { } func (the *FileSaveHelper) Save(filePath, fileContent string) { File, errC := os.Create(filePath) defer File.Close() if errC != nil { log.Printf("创建文件失败 path=%s,err=%s", filePath, errC.Error()) } _, err := io.Copy(File, strings.NewReader(fileContent)) if err != nil { log.Printf("文件写入失败 path=%s,err=%s", filePath, err.Error()) } log.Printf("[%v]存储文件 长度=%d ", filePath, len(fileContent)) }