标签 windows 下的文章

windows创建文件夹时不能包含一些特殊符号


QQ图片20200922181733.png

Go中使用字符串替换即可

//文件夹不能包含 \ / : * ? " < > |
dirName = strings.Replace(dirName, "\\", "", -1)
dirName = strings.Replace(dirName, "/", "", -1)
dirName = strings.Replace(dirName, ":", "", -1)
dirName = strings.Replace(dirName, "*", "", -1)
dirName = strings.Replace(dirName, "?", "", -1)
dirName = strings.Replace(dirName, "\"", "", -1)
dirName = strings.Replace(dirName, "<", "", -1)
dirName = strings.Replace(dirName, ">", "", -1)
dirName = strings.Replace(dirName, "|", "", -1)