Why golang does not implement FILE-level visible variable


(zylthinking) #1

Like static int n = 0 in C.
I prefer this because I am totally trapped in variables naming — I have to add long and strange prefixes to make sure variables name is unique in different files of the same packet , It is obviously not reasonable to move the code to another packet just because of the conflicts of names.


(Norbert Melzer) #2

Having variables in package scope is a code smell in itself. You should try to avoid them at all costs, try to share data via channels instead.