The Goldberg-Sachs theorem is generalized for all four-dimensional manifolds endowed with torsion-free connection compatible with the metric, the treatment includes all signatures as well as complex manifolds. It is shown that when the Weyl tensor is algebraically special severe geometric restrictions are imposed. In particular it is demonstrated that the simple self-dual eigenbivectors of the Weyl tensor generate integrable isotropic planes. Another result obtained here is that if the self-dual part of the Weyl tensor vanishes in a Ricci-flat manifold of (2,2) signature the manifold must be Calabi-Yau or symplectic and admits a solution for the source-free Einstein-Maxwell equations. In this paper the term "complexified manifold" means a manifold in which the metric can be complex, so that the Weyl tensor is also generally complex. The here called "real manifolds" are the ones with real metric and, consequently, real Weyl tensor. In general the tangent bundle of the real manifolds will be assumed to be complexified. Finally, the term "complex manifold" will mean a manifold that can be covered by complex charts with analytic transition functions, these manifolds are sometimes called Hermitian.