Pros and cons of Go rejecting unused dependencies

dependencies, go, language-design

Solution

Not only you need to explicitly use all dependencies, but also all variables must be used. The compiler will give you errors when you have unused variables.

They are annoying. But it will make others happy because they get clean code.

I'm thinking that probably Go designers intended Go to be a language that is largely IDE dependent.

Problem

Google's new language Go tries to make dependencies management easier by explicitly requiring that all dependencies listed in a module actually be used. The compiler will reject a module that declares a dependency to a module without using anything from that module. It is illegal for a package to import itself or to import a package without referring to any of its exported identifiers. I can think of some obvious advantages (e.g. cleaner modules) but maybe there are some non-obvious ones. The only disadvantage I can think of is having an overly pedantic compiler, complaining too much during refactoring, but maybe there are more? Do you have any experience with other languages enforcing this? What are the pros and cons of this approach?

Original source