golang错误:The process cannot access the file because it is being used by another process
生活随笔
收集整理的這篇文章主要介紹了
golang错误: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() //關閉文件 }情況二,LiteIDE進程沖突:
func main() {db, err := sql.Open("mysql", "aaaa:123456@tcp(192.168.1.106:3306)/mirai?charset=utf8")if err != nil {fmt.Println("鏈接錯誤1");}err = db.Ping()if err != nil {fmt.Println("鏈接錯誤2");}db.Close() }刪除進程:
總結
以上是生活随笔為你收集整理的golang错误:The process cannot access the file because it is being used by another process的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python twisted教程 三–开
- 下一篇: ubuntu安装python3、setu