1.新建文件后再删除失败,提示文件正在被另一程序使用中(The process cannot access the file because it is being used by another process.)
func main() { NewConfigIni() DeleteConfigTemp() } func DeleteConfigTemp() { path := "time.ini" err := os.Remove(path) //如果文件不存在时执行会报错 fmt.Println("删除ini err:",err) } func NewConfigIni() { os.Create("time.ini") }
修正:
func NewConfigIni() { f,_ := os.Create("time.ini") f.Close() //关闭文件 }原文链接:https://www.f2er.com/go/190772.html