In the US the policy is:
A United States government work is prepared by an officer or employee of the United States government as part of that person's official duties.
It is not subject to copyright in the United States and there are no copyright restrictions on reproduction, derivative works, distribution, performance, or display of the work. Anyone may, without restriction under U.S. copyright laws:
- reproduce the work in print or digital form
- create derivative works
- perform the work publicly
- display the work
- distribute copies or digitally transfer the work to the public by sale or other transfer of ownership, or by rental, lease, or lending.
US government based software developer agencies like 18f and USDS (United States Digital Service) license all of their code to the public domain.
The UK is slightly different:
But there is the OGL (Open Government License):