600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 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

时间:2022-07-10 12:18:01

相关推荐

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()}

删除进程:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。