Created
March 20, 2014 19:03
-
-
Save cespare/9671365 to your computer and use it in GitHub Desktop.
Revisions
-
cespare revised this gist
Mar 20, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ $ go run unused.go container/ring debug/gosym debug/pe -
cespare created this gist
Mar 20, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ $ go run deps.go container/ring debug/gosym debug/pe encoding/ascii85 encoding/csv expvar go/build hash/crc64 hash/fnv index/suffixarray log/syslog net/http/cookiejar net/http/fcgi net/http/pprof net/mail net/rpc/jsonrpc net/smtp os/user runtime/cgo runtime/race text/scanner This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ // Print a list of stdlib packages not used in the stdlib. package main import ( "bytes" "fmt" "go/build" "log" "os/exec" "strings" ) func main() { // Use 'go list std' to get a list of stdlib packages. // Maybe there's a better way. out, err := exec.Command("go", "list", "std").Output() if err != nil { log.Fatal(err) } var pkgs []string for _, name := range bytes.Fields(out) { pkg := string(name) if !strings.HasPrefix(pkg, "cmd/") { pkgs = append(pkgs, string(name)) } } used := make(map[string]bool) for _, name := range pkgs { pkg, err := build.Import(name, "", 0) if err != nil { log.Fatal(err) } imports := append(pkg.Imports, pkg.TestImports...) imports = append(imports, pkg.XTestImports...) for _, imp := range imports { used[imp] = true } } for _, name := range pkgs { if !used[name] { fmt.Println(name) } } }