This is a creation in Article, where the information may have evolved or changed.
Because of their own PC notebook, with a poor 120G SSD hard disk, compared to the vast Win7,vs now, hard disk space is poor, often lead to insufficient hard disk space. There's no way, every time human flesh clears temporary files such as
vs compile, the. pdb file that is generated when the. obj file is connected is also the. sdf file that VS2010 introduced to improve smart hints.
So think of using the program to automatically implement this function, just learning the go language, all when practiced hand.
The simple procedure is to start from a directory recursively and delete certain types of files
My first go Little program, dirty files for VSPackage mainimport ("FMT" "OS" "Path" "strings") var Filetypes2clean = []string{". sdf", ". obj", ". pdb", ". TLog"}func main () {Dir_to_clean, _: = OS. GETWD () filecount, dirtysize: = Clean_dirtyfiles (Dir_to_clean) fmt. Printf ("Total delete%d files,%d mbytes\n", FileCount, dirtysize>>10>>10)}func clean_dirtyfiles (dir string ) (FileCount Int64, dirtysize Int64) {//fmt. Println ("to \ Dirty files for" + dir) f_dir, err: = OS. Open (dir) if err! = Nil {fmt. PRINTLN (Err) return}//enum Filesfis, Err_readdir: = F_dir. Readdir ( -1) if err_readdir! = nil {fmt. Println (Err_readdir) Return}for _, Fi: = Range fis {file_name: = fi. Name () if!path. Isabs (file_name) {file_name = path. Join (dir, file_name)}if fi. Isdir () {sub_filecount, Sub_dirtysize: = Clean_dirtyfiles (file_name) FileCount + = sub_filecountdirtysize + = Sub_ Dirtysizecontinue}file_ext: = Strings. ToLower (path. Ext (file_name)) for _, Ext: = Range Filetypes2clean {if ext! = file_ext {continue}fSize: = Fi. Size () Err_rm: = OS. Remove (file_name) if err_rm = = Nil {FileCount + = 1dirtysize + = fsizefmt. Println ("Delete:" + file_name)} else {fmt. Println (ERR_RM)}}//for _, Ext: = range}//return}