Global variable private to file

For the purpose of variable scoping, files have no meaning in Go. Think of all files in a package as if they would be concatenated, which (simplified) is exactly what happens before compilation.

That means: No, there is no way of scoping a variable to a file.

If you need two global WaitGroups, you need to define them as individual variables.

Leave a Comment