OK, I may have misunderstood. Of course the government can discriminate if their is a compelling government interest. But of course there is no compelling government interest in discriminating against gays as a function of government. Hell, not only does it not have a compelling government interest, it doesn't even rise to the rational basis test standard.
Take for example Colorado's Amendment 2 which attempted to strip equality from homosexuals and leave them with no legal recourse to challenge discrimination, not only at the State level is voided even local laws that attempted to provide legal recourse. In Romer v. Evans the court stated:
"The Fourteenth Amendment's promise that no person shall be denied the equal protection of the laws must co-exist with the practical necessity that most legislation classifies for one purpose or another, with resulting disadvantage to various groups or persons. Personnel Administrator of Mass. v. Feeney, 442 U.S. 256, 271- 272 (1979); F. S. Royster Guano Co. v. Virginia, 253 U.S. 412, 415 (1920). We have attempted to reconcile the principle with the reality by stating that, if a law neither burdens a fundamental right nor targets a suspect class, we will uphold the legislative classification so long as it bears a rational relation to some legitimate end. See, e.g., Heller v. Doe, 509 U.S. ___, ___ (1993) (slip op., at 6).
Amendment 2 fails, indeed defies, even this conventional inquiry. First, the amendment has the peculiar property of imposing a broad and undifferentiated disability on a single named group, an exceptional and, as we shall explain, invalid form of legislation. Second, its sheer breadth is so discontinuous with the reasons offered for it that the amendment seems inexplicable by anything but animus toward the class that it affects; it lacks a rational relationship to legitimate state interests."
Just to reiterate, the court said the the desire to discriminate against homosexuals lacked a rational basis.