Is there any way to clean unused packages in go mod directory? currently when you use go mod to manage you dependencies,new packages are added and old ones are not removed.
So can we maintain a global gomod.stats file to keep reference counter of every package? It can only be modified when executing `go mod download/init/tidy` and when running `go mod clean`, it will traverse gomod.stats and find packages who's refcount is 0 then delete them. This is similar to simplified GC using reference counting and I think customizing digraph may deal with it. https://en.wikipedia.org/wiki/Directed_graph https://en.wikipedia.org/wiki/Reference_counting#Graph_interpretation this is golang.org/x/tools packages in my GOPATH/pkg/mod, totally 32 directories with 41463 files and 16185 sub-directories. It's not necessary now but I think wo need it sooner or later. ``` D:\~\go\pkg\mod\golang.org\x>dir | findstr tools 2020/07/02 周四 19:36 <DIR> tools 2020/01/09 周四 23:02 <DIR> [email protected] 2020/01/09 周四 23:03 <DIR> [email protected] 2019/11/12 周二 15:00 <DIR> [email protected] 2020/01/09 周四 23:02 <DIR> [email protected] 2020/04/24 周五 14:47 <DIR> [email protected] 2019/11/20 周三 15:46 <DIR> [email protected] 2019/12/13 周五 17:16 <DIR> [email protected] 2020/01/09 周四 23:03 <DIR> [email protected] 2019/11/19 周二 14:59 <DIR> [email protected] 2019/11/19 周二 14:59 <DIR> [email protected] 2020/01/09 周四 23:03 <DIR> [email protected] 2019/12/11 周三 16:41 <DIR> [email protected] 2019/12/11 周三 16:41 <DIR> [email protected] 2020/01/09 周四 23:02 <DIR> [email protected] 2020/02/28 周五 10:24 <DIR> [email protected] 2020/02/18 周二 16:59 <DIR> [email protected] 2020/02/18 周二 16:59 <DIR> [email protected] 2020/04/30 周四 15:41 <DIR> [email protected] 2020/03/03 周二 12:29 <DIR> [email protected] 2020/02/28 周五 10:23 <DIR> [email protected] 2020/03/03 周二 12:29 <DIR> [email protected] 2020/06/15 周一 22:39 <DIR> [email protected] 2020/03/25 周三 16:50 <DIR> [email protected] 2020/03/25 周三 16:50 <DIR> [email protected] 2020/04/10 周五 17:48 <DIR> [email protected] 2020/04/10 周五 17:48 <DIR> [email protected] 2020/04/30 周四 15:40 <DIR> [email protected] 2020/05/11 周一 21:46 <DIR> [email protected] 2020/05/15 周五 09:43 <DIR> [email protected] 2020/05/15 周五 09:43 <DIR> [email protected] 2020/07/02 周四 19:36 <DIR> [email protected] 2020/07/02 周四 19:36 <DIR> [email protected] ``` Thanks. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1f46b3cc-6434-4589-822e-a38464bc1387n%40googlegroups.com.
