Throughout, we assume with no loss of generality that $f$ and $g_n$ are nonnegative, since if we prove the theorem replacing $f$ and $g_n$ with $|f|$ and $|g_n|$ then the result follows.
[Update: the original proof used machinery that you might not have been exposed to and that on reflection is not really necessary, so I have included an alternative argument using only dominated convergence.]
Proof via dominated convergence
Let $\delta>0$. Now, for sufficiently small $\epsilon>0$ and $\eta>0$ we have (by dominated convergence)
$$\int_{\{f>\frac{1}{\epsilon}\}\cup \{f<\eta\}}f^2\leq \delta^2\text{.}$$
To see that this follows from dominated convergence, just observe that the sequence of functions
$f^2\chi_{\{f>m\}\cup \{f<\frac{1}{m}\}}$ converges pointwise to $0$ and is dominated by $f^2$.
Therefore for all $g_n$ we have
$$\int_{\{f>\frac{1}{\epsilon}\}\cup \{f<\eta\}}fg_n
\leq
\left(\int_{\{f>\frac{1}{\epsilon}\}\cup \{f<\eta\}}f^2\right)^{\frac{1}{2}}\cdot \left(\int_{\{f>\frac{1}{\epsilon}\}\cup \{f<\eta\}}g_n^2\right)^{\frac{1}{2}}
\leq
\delta\text{.}\tag{1}$$
Fixing any such $\eta$ and $\epsilon$, we also have your inequalities, but with the integrands restricted further to $\{\eta\leq f\leq\frac{1}{\epsilon}\}$, and also we will actually choose $N$ large enough so that for $n>N$ we have $m(\{|g_n|>\epsilon^3\})<\epsilon^3$, so that for large enough $n$ we get
\begin{align*}
\int_{\{\eta\leq f\leq\frac{1}{\epsilon}\}} fg_n & \leq \left(\int_{\{g_n>\epsilon^3\}\cap \{\eta\leq f\leq\frac{1}{\epsilon}\}}f^2 \right)^{1/2}\left(\int_{\{g_n>\epsilon^3\}\cap\{\eta\leq f\leq\frac{1}{\epsilon}\}}g_n^2 \right)^{1/2} \\ &+ \epsilon^3\int_{\{g_n\leq\epsilon^3\}\cap\{\eta\leq f\leq\frac{1}{\epsilon}\}}f\tag{2}\\
& \leq \epsilon^{\frac{1}{2}}\cdot 1 + \frac{\epsilon^3}{\eta}\int_{\{g_n\leq\epsilon^3\}\cap\{\eta\leq f\leq\frac{1}{\epsilon}\}}f^2
\end{align*}
Then letting $\epsilon\to 0$ and combining (1) and (2) gives
$$\overline{\lim_{n\to\infty}}\int fg_n \leq \overline{\lim_{n\to\infty}}\int_{\{f>\frac{1}{\epsilon}\}\cup \{f<\eta\}}fg_n + \overline{\lim_{n\to\infty}}\int_{\{\eta\leq f\leq\frac{1}{\epsilon}\}} fg_n\leq \delta\text{,}
$$
and since $\delta$ was arbitrary this completes the proof.
Proof via Banach–Alaoglu theorem
From the subsequence principle it is enough to show that every subsequence of $\int fg_n$ has a further subsequence which converges to $0$. But since every subsequence of $g_n$ satisfies the assumptions of the original sequence, this reduces our task to finding a single subsequence of the original sequence $\int fg_n$ that converges.
Now, by the weak-* compactness of the ball in $L^2(\mathbb R)$, there is a subsequence of $g_n$ (which we immediately rename as $g_n$ itself) that converges weak-* to some $g\in L^2(\mathbb R)$, i.e., $\int h g_n\to \int hg$ for each $h\in L^2(\mathbb R)$. (Here we are also using the characterization of the dual of $L^2$ via the Riesz representation theorem)
It therefore suffices to show that $g=0$ almost everywhere, as we may take $h=f$. Equivalently, we will show that $\int_A g=0$ for all $A$ with $m(A)<\infty$. To do this, we fix such $A$ and then simply repeat your calculation replacing $f$ with $\chi_A$:
\begin{align*}
\int \chi_A g_n & \leq \int_{\{g_n>\epsilon\}}\chi_A g_n+\int_{\{g_n\leq\epsilon\}}\chi_A g_n\\
&\leq \left(\int_{\{g_n>\epsilon\}}\chi_A^2 \right)^{1/2}\left(\int_{\{g_n>\epsilon\}}g_n^2 \right)^{1/2} + \epsilon\int_{\{g_n\leq\epsilon\}}\chi_A\\
& \leq \epsilon^{1/2}\cdot 1 + \epsilon m(A)
\end{align*}
and so letting $\epsilon\to 0$ establishes that $\int g_n\chi_A\to 0$, whereby from weak convergence of $g_n$ we have $\int_A g = \int g\chi_A=0$, as desired.