I am looking for a formal proof of the following:
$\mathbb E[g_2(Y) \cdot g_1(X)|Y]=g_2(Y) \cdot \mathbb E[g_1(X)|Y]$ where $X$ and $Y$ are continuous random variables and $g_1, g_2$ are some functions (not sure what conditions must be imposed on them).
Would be thankful for a reference to the proof.
For references, any good book that uses a measure-theoretic approach to probability theory should have this. For instance,
David William's "Probability with Martingales" (Cambridge University Press, 1991), Sections 9.7, 9.8;
Jeffrey Rosenthal's "A First look at Rigorous Probability Theory" (2nd edition, World Scientific Publishing Co., 2008), Proposition 13.2.6;
One can show this using "the standard machine" style of proof in measure theory, and it doesn't require the random variables to be continuous either. You do, however, want $g_2(Y)$ to be $\sigma(Y)$-measurable. In addition, $~g_1(X)~$ and $~g_1(X)\,g_2(Y)~$ should be integrable (i.e. their expectations exist).