Why golang does not implement FILE-level visible variable

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.

1 Like

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.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.