On Monday, 12 September 2016 08:57:15 UTC-4, Markus Zimmermann wrote: > > Hi gophers! > > I am wondering why we have a "declared and not used" compile error for > variables [https://play.golang.org/p/KLzHVO5L7q] but not for constants [ > https://play.golang.org/p/JG9dSa_VKg]? I am sure there is some rational > decision behind this that I have missed, but my Google-fu is just not > strong enough to find an answer. >
I suspect the answer is: because unused constants and types cost nothing at run time. It's not that simple, of course, because constant and type declarations may be the only uses of an import of a package whose initialization has some cost; but this is quite marginal. -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.