If I'm understanding correctly, in a broad sense, "government code" means programming or systems a government uses in any way.
Then the answer, generally speaking, is no; obviously, "government code shouldn't be open-sourced by default". For the simple reason that if the public, or anyone, has access to it, then so does the "enemy" or anyone going against the legitimate and lawful will of the people of that country.
Allowing "the enemy" or anyone that's illegitimate and immoral to work against the legitimate and moral will of a group of people, aka country X, is irrational and immoral.
The issue isn't the benefits of millions of people using their free will and experience to test and improve X. I completely agree with these concepts or principles for many reasons. The issue is that they can't be applied in a vacuum; they assume everyone involved has the same values, goals, or X.
The fact that there are always some who disagree or are willing to impede the X in any way, for whatever reason, means that the "government code" shown or "open-sourced" will inevitably be detrimentaly be used against the X.
It logically follows that's true and inevitable.