github.com/zxy12/go_duplicate_1_12@v0.0.0-20200217043740-b1636fc0368b/src/cmd/dist/cmdclean.go (about) 1 package main 2 3 import ( 4 "strings" 5 ) 6 7 func clean() { 8 9 for _, name := range cleanlist { 10 path := pathf("%s/src/%s", goroot, name) 11 12 // Remove generated files. 13 for _, elem := range xreaddir(path) { 14 for _, gt := range gentab { 15 if strings.HasPrefix(elem, gt.nameprefix) { 16 xremove(pathf("%s/%s", path, elem)) 17 } 18 } 19 } 20 // Remove generated binary named for directory. 21 if strings.HasPrefix(name, "cmd/") { 22 xremove(pathf("%s/%s", path, name[4:])) 23 } 24 } 25 26 // remove runtimegen files. 27 path := pathf("%s/src/runtime", goroot) 28 for _, elem := range runtimegen { 29 xremove(pathf("%s/%s", path, elem)) 30 } 31 32 if rebuildall { 33 // Remove object tree. 34 xremoveall(pathf("%s/pkg/obj/%s_%s", goroot, gohostos, gohostarch)) 35 36 // Remove installed packages and tools. 37 xremoveall(pathf("%s/pkg/%s_%s", goroot, gohostos, gohostarch)) 38 xremoveall(pathf("%s/pkg/%s_%s", goroot, goos, goarch)) 39 xremoveall(pathf("%s/pkg/%s_%s_race", goroot, gohostos, gohostarch)) 40 xremoveall(pathf("%s/pkg/%s_%s_race", goroot, goos, goarch)) 41 xremoveall(tooldir) 42 43 // Remove cached version info. 44 xremove(pathf("%s/VERSION.cache", goroot)) 45 } 46 }