When I compile, it says 'recursive call during initialization'
The possible reason is what I said above.
Now my question is, may I use a global variable?
I know using global variables is not a good practice, then is there
alternative ways?
How to improve the design of the code?
mutually referring packages aren't allowed in Go.
your best bet is either to merge the packages or
shuffle things so there's no mutual reference (e.g. move
the const definition into package b)
--
To unsubscribe, reply using "remove me" as the subject.
This sounds like you have a design problem. If package a and package b
are so interlinked you should just make them the same package(you can
spread a package over multiple files).
posting a link to your code might help as help you with the design issues.
- jessta
--
=====================
http://jessta.id.au
The solution of making packages so large that they include everything
they might need access to doesn't appeal to me, even if you ARE allowed
to divide a package among multiple files.
I also feel that go has a weakness in the control of variable
visibility, but I'm not sure about this yet.
Global variables are certainly to be avoided. Even if one really DOES
need something to be global, one should always consider breaking it out
into a package that can be included where needed.